From 825b528f398db05c2e9d098538c319bed571e716 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Thu, 12 Feb 2026 12:56:04 +0100 Subject: [PATCH 01/13] update python sdk Strip any directory traversal # Conflicts: # docs/generators/java-camel.md # docs/generators/spring.md # modules/openapi-generator/src/main/resources/python/api_client.mustache # Conflicts: # samples/client/others/c/bearerAuth/README.md # samples/client/petstore/ada/.openapi-generator/VERSION # samples/client/petstore/ada/src/client/samples-petstore-clients.adb # samples/client/petstore/ada/src/client/samples-petstore-clients.ads # samples/client/petstore/ada/src/model/samples-petstore-models.adb # samples/client/petstore/ada/src/model/samples-petstore-models.ads # samples/client/petstore/apex/.openapi-generator/VERSION # samples/openapi3/schema/petstore/avro-schema-issue6268/.openapi-generator/VERSION # samples/openapi3/schema/petstore/avro-schema/.openapi-generator/VERSION # samples/openapi3/schema/valid-enums/avro-schema-enum/.openapi-generator/VERSION # samples/server/petstore/aspnet/fastendpoints-useApiVersioning/.openapi-generator/VERSION # samples/server/petstore/aspnet/fastendpoints-useAuthentication/.openapi-generator/VERSION # samples/server/petstore/aspnet/fastendpoints-useProblemDetails/.openapi-generator/VERSION # samples/server/petstore/aspnet/fastendpoints-useRecords/.openapi-generator/VERSION # samples/server/petstore/aspnet/fastendpoints-useResponseCaching/.openapi-generator/VERSION # samples/server/petstore/aspnet/fastendpoints-useValidators/.openapi-generator/VERSION # samples/server/petstore/aspnet/fastendpoints/.openapi-generator/VERSION --- docs/generators/crystal.md | 4 +- docs/generators/groovy.md | 2 - docs/generators/java-dubbo.md | 2 - docs/generators/java-helidon-client.md | 2 - docs/generators/java-helidon-server.md | 2 - docs/generators/java-inflector.md | 2 - docs/generators/java-micronaut-client.md | 2 - docs/generators/java-micronaut-server.md | 2 - docs/generators/java-microprofile.md | 2 - docs/generators/java-msf4j.md | 2 - docs/generators/java-pkmst.md | 2 - docs/generators/java-play-framework.md | 2 - docs/generators/java-undertow-server.md | 2 - docs/generators/java-vertx-web.md | 2 - docs/generators/java-vertx.md | 2 - docs/generators/java-wiremock.md | 2 - docs/generators/java.md | 2 - docs/generators/jaxrs-cxf-cdi.md | 2 - docs/generators/jaxrs-cxf-client.md | 2 - docs/generators/jaxrs-cxf-extended.md | 2 - docs/generators/jaxrs-cxf.md | 2 - docs/generators/jaxrs-jersey.md | 2 - docs/generators/jaxrs-resteasy-eap.md | 2 - docs/generators/jaxrs-resteasy.md | 2 - docs/generators/jaxrs-spec.md | 2 - docs/generators/kotlin-server.md | 7 +- docs/generators/kotlin-spring.md | 6 +- docs/generators/protobuf-schema.md | 1 - docs/generators/python-fastapi.md | 2 +- docs/generators/swift5.md | 2 +- docs/generators/typescript-angular.md | 4 +- docs/generators/typescript-axios.md | 2 +- docs/generators/typescript.md | 1 - .../c/bearerAuth/include/keyValuePair.h | 17 -- samples/client/petstore/bash/docs/Name.md | 13 - .../c-useJsonUnformatted/model/order.c | 233 ------------------ samples/client/petstore/c/model/category.h | 40 --- .../src/Org.OpenAPITools/Program.cs | 33 --- .../src/Org.OpenAPITools/Program.cs | 33 --- .../src/Org.OpenAPITools/Program.cs | 33 --- .../src/Org.OpenAPITools/Program.cs | 33 --- .../src/Org.OpenAPITools/Program.cs | 33 --- .../src/Org.OpenAPITools/Program.cs | 33 --- .../Formatters/InputFormatterStream.cs | 45 ---- .../src/Org.OpenAPITools/Program.cs | 33 --- .../src/Org.OpenAPITools/Startup.cs | 150 ----------- .../src/Org.OpenAPITools/Program.cs | 33 --- .../src/Org.OpenAPITools/Program.cs | 33 --- .../src/Org.OpenAPITools/Program.cs | 33 --- .../src/Org.OpenAPITools/Program.cs | 33 --- .../Formatters/InputFormatterStream.cs | 45 ---- .../src/Org.OpenAPITools/Program.cs | 33 --- .../model/Category.cpp | 144 ----------- .../model/OuterType.cpp | 94 ------- 54 files changed, 10 insertions(+), 1244 deletions(-) diff --git a/docs/generators/crystal.md b/docs/generators/crystal.md index ea2b3cc400db..ba481b67e4da 100644 --- a/docs/generators/crystal.md +++ b/docs/generators/crystal.md @@ -94,7 +94,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • if
  • in
  • include
  • -
  • instance_sizeof
  • +
  • instance
  • is_a?
  • lib
  • macro
  • @@ -102,11 +102,9 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • next
  • nil
  • nil?
  • -
  • object_id
  • of
  • out
  • pointerof
  • -
  • previous_def
  • private
  • protected
  • require
  • diff --git a/docs/generators/groovy.md b/docs/generators/groovy.md index d5cdff849435..e2f1314c4bb1 100644 --- a/docs/generators/groovy.md +++ b/docs/generators/groovy.md @@ -30,12 +30,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-dubbo.md b/docs/generators/java-dubbo.md index 2ea83de8db02..fa64f3d35955 100644 --- a/docs/generators/java-dubbo.md +++ b/docs/generators/java-dubbo.md @@ -34,12 +34,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |configPackage|configuration package for generated code| |org.openapitools.configuration| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-helidon-client.md b/docs/generators/java-helidon-client.md index 06f803388070..5f309c81ce6b 100644 --- a/docs/generators/java-helidon-client.md +++ b/docs/generators/java-helidon-client.md @@ -33,8 +33,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |configKey|Config key in @RegisterRestClient. Default to none.| |null| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| diff --git a/docs/generators/java-helidon-server.md b/docs/generators/java-helidon-server.md index f456ed9ce064..b4d8db132743 100644 --- a/docs/generators/java-helidon-server.md +++ b/docs/generators/java-helidon-server.md @@ -32,8 +32,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| diff --git a/docs/generators/java-inflector.md b/docs/generators/java-inflector.md index 7054f33501ac..3adfffad38df 100644 --- a/docs/generators/java-inflector.md +++ b/docs/generators/java-inflector.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-micronaut-client.md b/docs/generators/java-micronaut-client.md index 645025f315d8..37a2d8907ee1 100644 --- a/docs/generators/java-micronaut-client.md +++ b/docs/generators/java-micronaut-client.md @@ -41,12 +41,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |dateFormat|Specify the format pattern of date as a string| |null| |dateLibrary|Option. Date library to use|
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| |datetimeFormat|Specify the format pattern of date-time as a string| |null| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-micronaut-server.md b/docs/generators/java-micronaut-server.md index 73fb9dd977ad..4a21268afbd5 100644 --- a/docs/generators/java-micronaut-server.md +++ b/docs/generators/java-micronaut-server.md @@ -36,12 +36,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |dateFormat|Specify the format pattern of date as a string| |null| |dateLibrary|Option. Date library to use|
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| |datetimeFormat|Specify the format pattern of date-time as a string| |null| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-microprofile.md b/docs/generators/java-microprofile.md index 7f87f275d343..9e02b37145ef 100644 --- a/docs/generators/java-microprofile.md +++ b/docs/generators/java-microprofile.md @@ -37,12 +37,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |configKeyFromClassName|If true, set tag as key in @RegisterRestClient. Default to false. Only `microprofile` supports this option.| |null| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-msf4j.md b/docs/generators/java-msf4j.md index 25842d8df871..7251308c1440 100644 --- a/docs/generators/java-msf4j.md +++ b/docs/generators/java-msf4j.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-pkmst.md b/docs/generators/java-pkmst.md index fc5e849f837b..e2299587c5f2 100644 --- a/docs/generators/java-pkmst.md +++ b/docs/generators/java-pkmst.md @@ -33,12 +33,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-play-framework.md b/docs/generators/java-play-framework.md index f30134f8ec8c..c5f80ab75d16 100644 --- a/docs/generators/java-play-framework.md +++ b/docs/generators/java-play-framework.md @@ -35,12 +35,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |controllerOnly|Whether to generate only API interface stubs without the server files.| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-undertow-server.md b/docs/generators/java-undertow-server.md index 1356bc33f589..c258e9aa5df4 100644 --- a/docs/generators/java-undertow-server.md +++ b/docs/generators/java-undertow-server.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-vertx-web.md b/docs/generators/java-vertx-web.md index e4156c53a887..473c40d1af7d 100644 --- a/docs/generators/java-vertx-web.md +++ b/docs/generators/java-vertx-web.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-vertx.md b/docs/generators/java-vertx.md index 5a8d19f0ee4f..dd2722079b63 100644 --- a/docs/generators/java-vertx.md +++ b/docs/generators/java-vertx.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-wiremock.md b/docs/generators/java-wiremock.md index e6f238f31ffc..39b0a40d6edf 100644 --- a/docs/generators/java-wiremock.md +++ b/docs/generators/java-wiremock.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java.md b/docs/generators/java.md index 85da80e56a9e..b98c5386e4e5 100644 --- a/docs/generators/java.md +++ b/docs/generators/java.md @@ -37,12 +37,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |configKeyFromClassName|If true, set tag as key in @RegisterRestClient. Default to false. Only `microprofile` supports this option.| |null| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md index eb7f94c2993d..02f6b177827e 100644 --- a/docs/generators/jaxrs-cxf-cdi.md +++ b/docs/generators/jaxrs-cxf-cdi.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md index bed567bf4f05..e735d8f0ef4b 100644 --- a/docs/generators/jaxrs-cxf-client.md +++ b/docs/generators/jaxrs-cxf-client.md @@ -33,12 +33,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md index 00971949946b..aeb82d2dce55 100644 --- a/docs/generators/jaxrs-cxf-extended.md +++ b/docs/generators/jaxrs-cxf-extended.md @@ -34,12 +34,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md index 7325c0b5965b..b9b120e2f8d9 100644 --- a/docs/generators/jaxrs-cxf.md +++ b/docs/generators/jaxrs-cxf.md @@ -34,12 +34,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-jersey.md b/docs/generators/jaxrs-jersey.md index 59186e03fa91..a5d3e9a3c51a 100644 --- a/docs/generators/jaxrs-jersey.md +++ b/docs/generators/jaxrs-jersey.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-resteasy-eap.md b/docs/generators/jaxrs-resteasy-eap.md index ce5dd75fe065..85a3ea082300 100644 --- a/docs/generators/jaxrs-resteasy-eap.md +++ b/docs/generators/jaxrs-resteasy-eap.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-resteasy.md b/docs/generators/jaxrs-resteasy.md index f451f945b804..c03831051659 100644 --- a/docs/generators/jaxrs-resteasy.md +++ b/docs/generators/jaxrs-resteasy.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md index a36ac50aef17..03c2d043bf78 100644 --- a/docs/generators/jaxrs-spec.md +++ b/docs/generators/jaxrs-spec.md @@ -32,12 +32,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| -|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| -|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/kotlin-server.md b/docs/generators/kotlin-server.md index 86859ea27401..733e819e6ce3 100644 --- a/docs/generators/kotlin-server.md +++ b/docs/generators/kotlin-server.md @@ -30,7 +30,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |featureHSTS|Avoid sending content if client already has same content, by checking ETag or LastModified properties.| |true| |featureMetrics|Enables metrics feature.| |true| |featureResources|Generates routes in a typed way, for both: constructing URLs and reading the parameters.| |true| -|fixJacksonJsonTypeInfoInheritance|When true (default), ensures Jackson polymorphism works correctly by: (1) always setting visible=true on @JsonTypeInfo, and (2) adding the discriminator property to child models with appropriate default values. When false, visible is only set to true if all children already define the discriminator property.| |true| |groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools| |interfaceOnly|Whether to generate only API interface stubs without the server files. This option is currently supported only when using jaxrs-spec library.| |false| |library|library template (sub-template)|
    **ktor**
    ktor framework
    **ktor2**
    ktor (2.x) framework
    **jaxrs-spec**
    JAX-RS spec only
    **javalin5**
    Javalin 5
    **javalin6**
    Javalin 6
    |ktor| @@ -263,11 +262,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ---- | --------- | ---------- | |Simple|✓|OAS2,OAS3 |Composite|✓|OAS2,OAS3 -|Polymorphism|✓|OAS2,OAS3 +|Polymorphism|✗|OAS2,OAS3 |Union|✗|OAS3 -|allOf|✓|OAS2,OAS3 +|allOf|✗|OAS2,OAS3 |anyOf|✗|OAS3 -|oneOf|✓|OAS3 +|oneOf|✗|OAS3 |not|✗|OAS3 ### Security Feature diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md index e03dfd102929..4eb0030c1734 100644 --- a/docs/generators/kotlin-spring.md +++ b/docs/generators/kotlin-spring.md @@ -44,8 +44,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |parcelizeModels|toggle "@Parcelize" for generated models| |null| |reactive|use coroutines for reactive behavior| |false| |requestMappingMode|Where to generate the class level @RequestMapping annotation.|
    **api_interface**
    Generate the @RequestMapping annotation on the generated Api Interface.
    **controller**
    Generate the @RequestMapping annotation on the generated Api Controller Implementation.
    **none**
    Do not add a class level @RequestMapping annotation.
    |controller| -|schemaImplements|A map of single interface or a list of interfaces per schema name that should be implemented (serves similar purpose as `x-kotlin-implements`, but is fully decoupled from the api spec). Example: yaml `schemaImplements: {Pet: com.some.pack.WithId, Category: [com.some.pack.CategoryInterface], Dog: [com.some.pack.Canine, com.some.pack.OtherInterface]}` implements interfaces in schemas `Pet` (interface `com.some.pack.WithId`), `Category` (interface `com.some.pack.CategoryInterface`), `Dog`(interfaces `com.some.pack.Canine`, `com.some.pack.OtherInterface`)| |empty map| -|schemaImplementsFields|A map of single field or a list of fields per schema name that should be prepended with `override` (serves similar purpose as `x-kotlin-implements-fields`, but is fully decoupled from the api spec). Example: yaml `schemaImplementsFields: {Pet: id, Category: [name, id], Dog: [bark, breed]}` marks fields to be prepended with `override` in schemas `Pet` (field `id`), `Category` (fields `name`, `id`) and `Dog` (fields `bark`, `breed`)| |empty map| |serializableModel|boolean - toggle "implements Serializable" for generated models| |null| |serverPort|configuration the port in which the sever is to run on| |8080| |serviceImplementation|generate stub service implementations that extends service interfaces. If this is set to true service interfaces will also be generated| |false| @@ -59,11 +57,9 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useFeignClientUrl|Whether to generate Feign client with url parameter.| |true| |useFlowForArrayReturnType|Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.| |true| |useResponseEntity|Whether (when false) to return actual type (e.g. List<Fruit>) and handle non-happy path responses via exceptions flow or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>). If disabled, method are annotated using a @ResponseStatus annotation, which has the status of the first response declared in the Api definition| |true| -|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot ≥ 3 (use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false| +|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false| |useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true| |useTags|Whether to use tags for creating interface and controller class names| |false| -|xKotlinImplementsFieldsSkip|A list of fields per schema name that should NOT be created with `override` keyword despite their presence in vendor extension `x-kotlin-implements-fields` for the schema. Example: yaml `xKotlinImplementsFieldsSkip: Pet: [photoUrls]` skips `override` for `photoUrls` in schema `Pet`| |empty map| -|xKotlinImplementsSkip|A list of fully qualified interfaces that should NOT be implemented despite their presence in vendor extension `x-kotlin-implements`. Example: yaml `xKotlinImplementsSkip: [com.some.pack.WithPhotoUrls]` skips implementing the interface in any schema| |empty list| ## SUPPORTED VENDOR EXTENSIONS diff --git a/docs/generators/protobuf-schema.md b/docs/generators/protobuf-schema.md index e01683760038..fc8616619336 100644 --- a/docs/generators/protobuf-schema.md +++ b/docs/generators/protobuf-schema.md @@ -22,7 +22,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |aggregateModelsName|Aggregated model filename. If set, all generated models will be combined into this single file.| |null| |customOptionsApi|Custom options for the api files.| |null| |customOptionsModel|Custom options for the model files.| |null| -|extractEnumsToSeparateFiles|Extract enums to separate protobuf files and import them in models| |false| |numberedFieldNumberList|Field numbers in order.| |false| |startEnumsWithUnspecified|Introduces "UNSPECIFIED" as the first element of enumerations.| |false| |supportMultipleResponses|Support multiple responses| |true| diff --git a/docs/generators/python-fastapi.md b/docs/generators/python-fastapi.md index 4e706a4c1a52..5a87a2fcee28 100644 --- a/docs/generators/python-fastapi.md +++ b/docs/generators/python-fastapi.md @@ -10,7 +10,7 @@ title: Documentation for the python-fastapi Generator | generator stability | BETA | | | generator type | SERVER | | | generator language | Python | | -| generator language version | 3.10 | | +| generator language version | 3.7 | | | generator default templating engine | mustache | | | helpTxt | Generates a Python FastAPI server (beta). Models are defined with the pydantic library | | diff --git a/docs/generators/swift5.md b/docs/generators/swift5.md index 68376d466186..9d565bf5993f 100644 --- a/docs/generators/swift5.md +++ b/docs/generators/swift5.md @@ -7,7 +7,7 @@ title: Documentation for the swift5 Generator | Property | Value | Notes | | -------- | ----- | ----- | | generator name | swift5 | pass this to the generate command after -g | -| generator stability | DEPRECATED | | +| generator stability | STABLE | | | generator type | CLIENT | | | generator language | Swift | | | generator default templating engine | mustache | | diff --git a/docs/generators/typescript-angular.md b/docs/generators/typescript-angular.md index f9f96573a4af..7d7c88af9979 100644 --- a/docs/generators/typescript-angular.md +++ b/docs/generators/typescript-angular.md @@ -11,7 +11,7 @@ title: Documentation for the typescript-angular Generator | generator type | CLIENT | | | generator language | Typescript | | | generator default templating engine | mustache | | -| helpTxt | Generates a TypeScript Angular (9.x - 21.x) client library. | | +| helpTxt | Generates a TypeScript Angular (9.x - 20.x) client library. | | ## CONFIG OPTIONS These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details. @@ -34,7 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original| |modelSuffix|The suffix of the generated model.| |null| |ngPackagrVersion|The version of ng-packagr compatible with Angular (see ngVersion option).| |null| -|ngVersion|The version of Angular. (At least 9.0.0)| |21.0.0| +|ngVersion|The version of Angular. (At least 9.0.0)| |20.0.0| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| |npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0| diff --git a/docs/generators/typescript-axios.md b/docs/generators/typescript-axios.md index 62f77eca1828..269c2b09587e 100644 --- a/docs/generators/typescript-axios.md +++ b/docs/generators/typescript-axios.md @@ -20,7 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |null| -|axiosVersion|Use this property to override the axios version in package.json| |^1.13.5| +|axiosVersion|Use this property to override the axios version in package.json| |^1.6.1| |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.
    |true| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| |enumNameSuffix|Suffix that will be appended to all enum names.| |Enum| diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 8616f926108d..5634f424a966 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -42,7 +42,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |supportsES6|Generate code that conforms to ES6.| |false| -|typescriptMajorVersion|Specify the major version of TypeScript to use in the client code. Default is 5.| |5| |useErasableSyntax|Use erasable syntax for the generated code. This is a temporary feature and will be removed in the future.| |false| |useInversify|Enable this to generate decorators and service identifiers for the InversifyJS inversion of control container. If you set 'deno' as 'platform', the generator will process this value as 'disable'.| |false| |useObjectParameters|Use aggregate parameter objects as function arguments for api operations instead of passing each parameter as a separate function argument.| |false| diff --git a/samples/client/others/c/bearerAuth/include/keyValuePair.h b/samples/client/others/c/bearerAuth/include/keyValuePair.h index cb839f29cdcf..e69de29bb2d1 100644 --- a/samples/client/others/c/bearerAuth/include/keyValuePair.h +++ b/samples/client/others/c/bearerAuth/include/keyValuePair.h @@ -1,17 +0,0 @@ -#ifndef _keyValuePair_H_ -#define _keyValuePair_H_ - -#include - -typedef struct keyValuePair_t { - char* key; - void* value; -} keyValuePair_t; - -keyValuePair_t *keyValuePair_create(char *key, void *value); - -keyValuePair_t* keyValuePair_create_allocate(char* key, double value); - -void keyValuePair_free(keyValuePair_t *keyValuePair); - -#endif /* _keyValuePair_H_ */ \ No newline at end of file diff --git a/samples/client/petstore/bash/docs/Name.md b/samples/client/petstore/bash/docs/Name.md index 295812c7bb7e..e69de29bb2d1 100644 --- a/samples/client/petstore/bash/docs/Name.md +++ b/samples/client/petstore/bash/docs/Name.md @@ -1,13 +0,0 @@ -# Name - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **integer** | | [default to null] -**snakeUnderscorecase** | **integer** | | [optional] [readonly] [default to null] -**property** | **string** | | [optional] [default to null] -**123Number** | **integer** | | [optional] [readonly] [default to null] - -[[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/c-useJsonUnformatted/model/order.c b/samples/client/petstore/c-useJsonUnformatted/model/order.c index d67d1d47c714..e69de29bb2d1 100644 --- a/samples/client/petstore/c-useJsonUnformatted/model/order.c +++ b/samples/client/petstore/c-useJsonUnformatted/model/order.c @@ -1,233 +0,0 @@ -#include -#include -#include -#include "order.h" - - -char* order_status_ToString(openapi_petstore_order_STATUS_e status) { - char* statusArray[] = { "NULL", "placed", "approved", "delivered" }; - return statusArray[status]; -} - -openapi_petstore_order_STATUS_e order_status_FromString(char* status){ - int stringToReturn = 0; - char *statusArray[] = { "NULL", "placed", "approved", "delivered" }; - size_t sizeofArray = sizeof(statusArray) / sizeof(statusArray[0]); - while(stringToReturn < sizeofArray) { - if(strcmp(status, statusArray[stringToReturn]) == 0) { - return stringToReturn; - } - stringToReturn++; - } - return 0; -} - -static order_t *order_create_internal( - long id, - long pet_id, - int quantity, - char *ship_date, - openapi_petstore_order_STATUS_e status, - int complete - ) { - order_t *order_local_var = malloc(sizeof(order_t)); - if (!order_local_var) { - return NULL; - } - order_local_var->id = id; - order_local_var->pet_id = pet_id; - order_local_var->quantity = quantity; - order_local_var->ship_date = ship_date; - order_local_var->status = status; - order_local_var->complete = complete; - - order_local_var->_library_owned = 1; - return order_local_var; -} - -__attribute__((deprecated)) order_t *order_create( - long id, - long pet_id, - int quantity, - char *ship_date, - openapi_petstore_order_STATUS_e status, - int complete - ) { - return order_create_internal ( - id, - pet_id, - quantity, - ship_date, - status, - complete - ); -} - -void order_free(order_t *order) { - if(NULL == order){ - return ; - } - if(order->_library_owned != 1){ - fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "order_free"); - return ; - } - listEntry_t *listEntry; - if (order->ship_date) { - free(order->ship_date); - order->ship_date = NULL; - } - free(order); -} - -cJSON *order_convertToJSON(order_t *order) { - cJSON *item = cJSON_CreateObject(); - - // order->id - if(order->id) { - if(cJSON_AddNumberToObject(item, "id", order->id) == NULL) { - goto fail; //Numeric - } - } - - - // order->pet_id - if(order->pet_id) { - if(cJSON_AddNumberToObject(item, "petId", order->pet_id) == NULL) { - goto fail; //Numeric - } - } - - - // order->quantity - if(order->quantity) { - if(cJSON_AddNumberToObject(item, "quantity", order->quantity) == NULL) { - goto fail; //Numeric - } - } - - - // order->ship_date - if(order->ship_date) { - if(cJSON_AddStringToObject(item, "shipDate", order->ship_date) == NULL) { - goto fail; //Date-Time - } - } - - - // order->status - if(order->status != openapi_petstore_order_STATUS_NULL) { - if(cJSON_AddStringToObject(item, "status", order_status_ToString(order->status)) == NULL) - { - goto fail; //Enum - } - } - - - // order->complete - if(order->complete) { - if(cJSON_AddBoolToObject(item, "complete", order->complete) == NULL) { - goto fail; //Bool - } - } - - return item; -fail: - if (item) { - cJSON_Delete(item); - } - return NULL; -} - -order_t *order_parseFromJSON(cJSON *orderJSON){ - - order_t *order_local_var = NULL; - - // order->id - cJSON *id = cJSON_GetObjectItemCaseSensitive(orderJSON, "id"); - if (cJSON_IsNull(id)) { - id = NULL; - } - if (id) { - if(!cJSON_IsNumber(id)) - { - goto end; //Numeric - } - } - - // order->pet_id - cJSON *pet_id = cJSON_GetObjectItemCaseSensitive(orderJSON, "petId"); - if (cJSON_IsNull(pet_id)) { - pet_id = NULL; - } - if (pet_id) { - if(!cJSON_IsNumber(pet_id)) - { - goto end; //Numeric - } - } - - // order->quantity - cJSON *quantity = cJSON_GetObjectItemCaseSensitive(orderJSON, "quantity"); - if (cJSON_IsNull(quantity)) { - quantity = NULL; - } - if (quantity) { - if(!cJSON_IsNumber(quantity)) - { - goto end; //Numeric - } - } - - // order->ship_date - cJSON *ship_date = cJSON_GetObjectItemCaseSensitive(orderJSON, "shipDate"); - if (cJSON_IsNull(ship_date)) { - ship_date = NULL; - } - if (ship_date) { - if(!cJSON_IsString(ship_date) && !cJSON_IsNull(ship_date)) - { - goto end; //DateTime - } - } - - // order->status - cJSON *status = cJSON_GetObjectItemCaseSensitive(orderJSON, "status"); - if (cJSON_IsNull(status)) { - status = NULL; - } - openapi_petstore_order_STATUS_e statusVariable; - if (status) { - if(!cJSON_IsString(status)) - { - goto end; //Enum - } - statusVariable = order_status_FromString(status->valuestring); - } - - // order->complete - cJSON *complete = cJSON_GetObjectItemCaseSensitive(orderJSON, "complete"); - if (cJSON_IsNull(complete)) { - complete = NULL; - } - if (complete) { - if(!cJSON_IsBool(complete)) - { - goto end; //Bool - } - } - - - order_local_var = order_create_internal ( - id ? id->valuedouble : 0, - pet_id ? pet_id->valuedouble : 0, - quantity ? quantity->valuedouble : 0, - ship_date && !cJSON_IsNull(ship_date) ? strdup(ship_date->valuestring) : NULL, - status ? statusVariable : openapi_petstore_order_STATUS_NULL, - complete ? complete->valueint : 0 - ); - - return order_local_var; -end: - return NULL; - -} diff --git a/samples/client/petstore/c/model/category.h b/samples/client/petstore/c/model/category.h index bd27e27e35a3..e69de29bb2d1 100644 --- a/samples/client/petstore/c/model/category.h +++ b/samples/client/petstore/c/model/category.h @@ -1,40 +0,0 @@ -/* - * category.h - * - * A category for a pet - */ - -#ifndef _category_H_ -#define _category_H_ - -#include -#include "../external/cJSON.h" -#include "../include/list.h" -#include "../include/keyValuePair.h" -#include "../include/binary.h" - -typedef struct category_t category_t; - - - - -typedef struct category_t { - long id; //numeric - char *name; // string - - int _library_owned; // Is the library responsible for freeing this object? -} category_t; - -__attribute__((deprecated)) category_t *category_create( - long id, - char *name -); - -void category_free(category_t *category); - -category_t *category_parseFromJSON(cJSON *categoryJSON); - -cJSON *category_convertToJSON(category_t *category); - -#endif /* _category_H_ */ - diff --git a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs index 18796da30fcb..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +++ b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -1,45 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.IO; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Formatters; - -namespace Org.OpenAPITools.Formatters -{ - /// - public class InputFormatterStream : InputFormatter - { - /// - public InputFormatterStream() - { - SupportedMediaTypes.Add("application/octet-stream"); - SupportedMediaTypes.Add("image/jpeg"); - } - - /// - public override Task ReadRequestBodyAsync(InputFormatterContext context) - { - return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); - } - - /// - protected override bool CanReadType(Type type) - { - if (type == typeof(Stream)) - { - return true; - } - - return false; - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs index bf30e991889e..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs @@ -1,150 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.IO; -using System.Reflection; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.OpenApi.Models; -using System.Text.Json; -using System.Text.Json.Serialization; -using Org.OpenAPITools.Authentication; -using Org.OpenAPITools.Filters; -using Org.OpenAPITools.OpenApi; -using Org.OpenAPITools.Formatters; - -namespace Org.OpenAPITools -{ - /// - /// Startup - /// - public class Startup - { - /// - /// Constructor - /// - /// - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - /// - /// The application configuration. - /// - public IConfiguration Configuration { get; } - - /// - /// This method gets called by the runtime. Use this method to add services to the container. - /// - /// - public void ConfigureServices(IServiceCollection services) - { - services.AddTransient(); - services.AddAuthorization(authConfig => - { - authConfig.AddPolicy("api_key", policyBuilder => - { - policyBuilder - .AddRequirements(new ApiKeyRequirement(new[] { "my-secret-key" },"api_key")); - }); - }); - - // Add framework services. - services - // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ - .AddControllers(options => { - options.InputFormatters.Insert(0, new InputFormatterStream()); - }) - .AddJsonOptions(options => - { - options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; - options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)); - }); - services - .AddSwaggerGen(c => - { - c.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true); - - c.SwaggerDoc("1.0.0", new OpenApiInfo - { - Title = "OpenAPI Petstore", - Description = "OpenAPI Petstore (ASP.NET Core 8.0)", - TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), - Contact = new OpenApiContact - { - Name = "OpenAPI-Generator Contributors", - Url = new Uri("https://github.com/openapitools/openapi-generator"), - Email = "" - }, - License = new OpenApiLicense - { - Name = "NoLicense", - Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0.html") - }, - Version = "1.0.0", - }); - c.CustomSchemaIds(type => type.FriendlyId(true)); - c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetExecutingAssembly().GetName().Name}.xml"); - // Sets the basePath property in the OpenAPI document generated - c.DocumentFilter("/v2"); - - // Include DataAnnotation attributes on Controller Action parameters as OpenAPI validation rules (e.g required, pattern, ..) - // Use [ValidateModelState] on Actions to actually validate it in C# as well! - c.OperationFilter(); - }); - } - - /// - /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - /// - /// - /// - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseHsts(); - } - - app.UseHttpsRedirection(); - app.UseDefaultFiles(); - app.UseStaticFiles(); - app.UseSwagger(c => - { - c.RouteTemplate = "openapi/{documentName}/openapi.json"; - }) - .UseSwaggerUI(c => - { - // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html - c.RoutePrefix = "openapi"; - //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) - c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "OpenAPI Petstore"); - - //TODO: Or alternatively use the original OpenAPI contract that's included in the static files - // c.SwaggerEndpoint("/openapi-original.json", "OpenAPI Petstore Original"); - }); - app.UseRouting(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs index 18796da30fcb..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -1,45 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.IO; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Formatters; - -namespace Org.OpenAPITools.Formatters -{ - /// - public class InputFormatterStream : InputFormatter - { - /// - public InputFormatterStream() - { - SupportedMediaTypes.Add("application/octet-stream"); - SupportedMediaTypes.Add("image/jpeg"); - } - - /// - public override Task ReadRequestBodyAsync(InputFormatterContext context) - { - return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); - } - - /// - protected override bool CanReadType(Type type) - { - if (type == typeof(Stream)) - { - return true; - } - - return false; - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs index 00ed16ed6758..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs @@ -1,33 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace Org.OpenAPITools -{ - /// - /// Program - /// - public class Program - { - /// - /// Main - /// - /// - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - /// - /// Create the host builder. - /// - /// - /// IHostBuilder - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup() - .UseUrls("http://0.0.0.0:8080/"); - }); - } -} diff --git a/samples/server/petstore/cpp-pistache-everything/model/Category.cpp b/samples/server/petstore/cpp-pistache-everything/model/Category.cpp index bd76b4cd6630..e69de29bb2d1 100644 --- a/samples/server/petstore/cpp-pistache-everything/model/Category.cpp +++ b/samples/server/petstore/cpp-pistache-everything/model/Category.cpp @@ -1,144 +0,0 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* 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. -*/ - - -#include "Category.h" -#include "Helpers.h" - -#include - -namespace org::openapitools::server::model -{ - -Category::Category() -{ - m_Id = 0L; - m_IdIsSet = false; - m_Name = ""; - m_NameIsSet = false; - -} - -void Category::validate() const -{ - std::stringstream msg; - if (!validate(msg)) - { - throw org::openapitools::server::helpers::ValidationException(msg.str()); - } -} - -bool Category::validate(std::stringstream& msg) const -{ - return validate(msg, ""); -} - -bool Category::validate(std::stringstream& msg, const std::string& pathPrefix) const -{ - bool success = true; - const std::string _pathPrefix = pathPrefix.empty() ? "Category" : pathPrefix; - - - if (nameIsSet()) - { - const std::string& value = m_Name; - const std::string currentValuePath = _pathPrefix + ".name"; - - - - } - - return success; -} - -bool Category::operator==(const Category& rhs) const -{ - return - - - - ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && - - - ((!nameIsSet() && !rhs.nameIsSet()) || (nameIsSet() && rhs.nameIsSet() && getName() == rhs.getName())) - - ; -} - -bool Category::operator!=(const Category& rhs) const -{ - return !(*this == rhs); -} - -void to_json(nlohmann::json& j, const Category& o) -{ - j = nlohmann::json::object(); - if(o.idIsSet()) - j["id"] = o.m_Id; - if(o.nameIsSet()) - j["name"] = o.m_Name; - -} - -void from_json(const nlohmann::json& j, Category& o) -{ - if(j.find("id") != j.end()) - { - j.at("id").get_to(o.m_Id); - o.m_IdIsSet = true; - } - if(j.find("name") != j.end()) - { - j.at("name").get_to(o.m_Name); - o.m_NameIsSet = true; - } - -} - -int64_t Category::getId() const -{ - return m_Id; -} -void Category::setId(int64_t const value) -{ - m_Id = value; - m_IdIsSet = true; -} -bool Category::idIsSet() const -{ - return m_IdIsSet; -} -void Category::unsetId() -{ - m_IdIsSet = false; -} -std::string Category::getName() const -{ - return m_Name; -} -void Category::setName(std::string const& value) -{ - m_Name = value; - m_NameIsSet = true; -} -bool Category::nameIsSet() const -{ - return m_NameIsSet; -} -void Category::unsetName() -{ - m_NameIsSet = false; -} - - -} // namespace org::openapitools::server::model - diff --git a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.cpp b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.cpp index f3cc1f8076b4..e69de29bb2d1 100644 --- a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.cpp +++ b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.cpp @@ -1,94 +0,0 @@ -/** -* Test swagger file -* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) -* -* 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. -*/ - - -#include "OuterType.h" -#include "Helpers.h" - -#include - -namespace org::openapitools::server::model -{ - -OuterType::OuterType() -{ - -} - -void OuterType::validate() const -{ - std::stringstream msg; - if (!validate(msg)) - { - throw org::openapitools::server::helpers::ValidationException(msg.str()); - } -} - -bool OuterType::validate(std::stringstream& msg) const -{ - return validate(msg, ""); -} - -bool OuterType::validate(std::stringstream& msg, const std::string& pathPrefix) const -{ - bool success = true; - const std::string _pathPrefix = pathPrefix.empty() ? "OuterType" : pathPrefix; - - - if (!m_Middle.validate(msg, _pathPrefix + ".middle")) { - msg << _pathPrefix << ": Middle is invalid;"; - success = false; - } - return success; -} - -bool OuterType::operator==(const OuterType& rhs) const -{ - return - - - (getMiddle() == rhs.getMiddle()) - - - ; -} - -bool OuterType::operator!=(const OuterType& rhs) const -{ - return !(*this == rhs); -} - -void to_json(nlohmann::json& j, const OuterType& o) -{ - j = nlohmann::json::object(); - j["middle"] = o.m_Middle; - -} - -void from_json(const nlohmann::json& j, OuterType& o) -{ - j.at("middle").get_to(o.m_Middle); - -} - -org::openapitools::server::model::MiddleType OuterType::getMiddle() const -{ - return m_Middle; -} -void OuterType::setMiddle(org::openapitools::server::model::MiddleType const& value) -{ - m_Middle = value; -} - - -} // namespace org::openapitools::server::model - From 9e2e0d5bc24f13efad8bd99192c6187eafeb0a9c Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Thu, 12 Feb 2026 13:47:11 +0100 Subject: [PATCH 02/13] imptove py sdk anyOf / allOf --- .../resources/python/model_anyof.mustache | 162 ++------- .../main/resources/python/model_doc.mustache | 8 +- .../resources/python/model_generic.mustache | 329 +++--------------- .../resources/python/model_oneof.mustache | 188 ++-------- samples/client/others/c/bearerAuth/src/list.c | 200 ----------- .../apex/config/project-scratch-def.json | 8 - samples/client/petstore/bash/docs/EnumTest.md | 14 - .../model/model_with_set_propertes.h | 41 --- .../client/petstore/c/model/api_response.c | 142 -------- .../client/petstore/cpp-oatpp/model/Tag.hpp | 51 --- .../src/Org.OpenAPITools/appsettings.json | 8 - .../src/Org.OpenAPITools/appsettings.json | 8 - .../src/Org.OpenAPITools/appsettings.json | 8 - .../src/Org.OpenAPITools/appsettings.json | 8 - .../src/Org.OpenAPITools/Dockerfile | 32 -- .../src/Org.OpenAPITools/appsettings.json | 8 - .../OpenApi/TypeExtensions.cs | 61 ---- .../Org.OpenAPITools/Org.OpenAPITools.nuspec | 20 -- .../src/Org.OpenAPITools/appsettings.json | 8 - .../src/Org.OpenAPITools/Dockerfile | 32 -- .../src/Org.OpenAPITools/Dockerfile | 32 -- .../src/Org.OpenAPITools/appsettings.json | 8 - .../Org.OpenAPITools/Org.OpenAPITools.csproj | 27 -- .../src/Org.OpenAPITools/Dockerfile | 32 -- .../Org.OpenAPITools/Org.OpenAPITools.nuspec | 20 -- .../src/Org.OpenAPITools/appsettings.json | 8 - .../Properties/launchSettings.json | 30 -- .../server/petstore/cpp-oatpp/model/Tag.hpp | 51 --- .../model/Category.cpp | 144 ++++++++ .../cpp-pistache-everything/model/Order.h | 124 ------- .../model/OuterType.h | 77 ---- 31 files changed, 253 insertions(+), 1636 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index e035e4829b6f..8d1899716b69 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -1,6 +1,4 @@ from __future__ import annotations -from inspect import getfullargspec -import json import pprint import re # noqa: F401 {{#vendorExtensions.x-py-other-imports}} @@ -11,167 +9,57 @@ import re # noqa: F401 {{/vendorExtensions.x-py-model-imports}} from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field +from pydantic import Field, RootModel {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}] -class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}): + +class {{classname}}(RootModel[Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}]]): """ {{{description}}}{{^description}}{{{classname}}}{{/description}} """ -{{#composedSchemas.anyOf}} - # data type: {{{dataType}}} - {{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}} -{{/composedSchemas.anyOf}} - if TYPE_CHECKING: - actual_instance: Optional[Union[{{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { {{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}} } - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } -{{#discriminator}} + root: Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}{{#isNullable}}, None{{/isNullable}}] = Field( + {{#isNullable}}None{{/isNullable}}{{^isNullable}}...{{/isNullable}}{{#discriminator}}, discriminator="{{discriminatorName}}"{{/discriminator}} + ) - discriminator_value_class_map: Dict[str, str] = { -{{#children}} - '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}},{{/-last}} -{{/children}} - } -{{/discriminator}} + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) + if name in self.__dict__: + return super().__getattribute__(name) - @field_validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - {{#isNullable}} - if v is None: - return v + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) - {{/isNullable}} - instance = {{{classname}}}.model_construct() - error_messages = [] - {{#composedSchemas.anyOf}} - # validate data type: {{{dataType}}} - {{#isContainer}} - try: - instance.{{vendorExtensions.x-py-name}} = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isContainer}} - {{^isContainer}} - {{#isPrimitiveType}} - try: - instance.{{vendorExtensions.x-py-name}} = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isPrimitiveType}} - {{^isPrimitiveType}} - if not isinstance(v, {{{dataType}}}): - error_messages.append(f"Error! Input type `{type(v)}` is not `{{{dataType}}}`") - else: - return v - - {{/isPrimitiveType}} - {{/isContainer}} - {{/composedSchemas.anyOf}} - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in {{{classname}}} with anyOf schemas: {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. Details: " + ", ".join(error_messages)) - else: - return v + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Self: - return cls.from_json(json.dumps(obj)) + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - {{#isNullable}} - if json_str is None: - return instance - - {{/isNullable}} - error_messages = [] - {{#composedSchemas.anyOf}} - {{#isContainer}} - # deserialize data into {{{dataType}}} - try: - # validation - instance.{{vendorExtensions.x-py-name}} = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.{{vendorExtensions.x-py-name}} - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isContainer}} - {{^isContainer}} - {{#isPrimitiveType}} - # deserialize data into {{{dataType}}} - try: - # validation - instance.{{vendorExtensions.x-py-name}} = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.{{vendorExtensions.x-py-name}} - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isPrimitiveType}} - {{^isPrimitiveType}} - # {{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}} - try: - instance.actual_instance = {{{dataType}}}.from_json(json_str) - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isPrimitiveType}} - {{/isContainer}} - {{/composedSchemas.anyOf}} - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into {{{classname}}} with anyOf schemas: {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) + return self.model_dump_json(by_alias=True, exclude_none=True) - def to_dict(self) -> Optional[Union[Dict[str, Any], {{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) + {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} 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 98d50cf8e6ea..5cc9d273dfb3 100644 --- a/modules/openapi-generator/src/main/resources/python/model_doc.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_doc.mustache @@ -19,14 +19,14 @@ from {{modelPackage}}.{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}} im # TODO update the JSON string below json = "{}" # create an instance of {{classname}} from a JSON string -{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_instance = {{classname}}.from_json(json) +{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_instance = {{classname}}.model_validate_json(json) # print the JSON string representation of the object -print({{classname}}.to_json()) +print({{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_dict = {{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_instance.to_dict() +{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_dict = {{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_instance.model_dump(by_alias=True) # create an instance of {{classname}} from a dict -{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_from_dict = {{classname}}.from_dict({{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_dict) +{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_from_dict = {{classname}}.model_validate({{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_dict) ``` {{/isEnum}} {{#isEnum}} diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index 70804d448de0..42089bfa2c08 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -10,7 +10,8 @@ import json {{{.}}} {{/vendorExtensions.x-py-model-imports}} from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field {{#hasChildren}} {{#discriminator}} @@ -28,7 +29,41 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#description}}{{{description}}}{{/description}}{{^description}}{{{classname}}}{{/description}} """ # noqa: E501 {{#vars}} + {{#isEnum}} + {{#allowableValues}} + {{^isArray}} + {{#values}} + {{#-first}} + {{#-last}} + {{! Single value enum - use Literal }} + {{name}}: Literal['{{{.}}}'] = Field( + {{#required}}...{{/required}}{{^required}}None{{/required}}, + description="{{description}}{{^description}}{{{name}}} of the {{classname}}{{/description}}", + alias="{{{baseName}}}" + ) + {{/-last}} + {{^-last}} + {{! Multiple value enum - use Literal for inline enums }} + {{name}}: {{#required}}Literal[{{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]{{/required}}{{^required}}Optional[Literal[{{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]]{{/required}} = Field( + {{#required}}...{{/required}}{{^required}}None{{/required}}, + description="{{description}}{{^description}}{{{name}}} of the {{classname}}{{/description}}" + ) + {{/-last}} + {{/-first}} + {{/values}} + {{/isArray}} + {{#isArray}} + {{! Array enum - use List[Literal] }} + {{name}}: {{#required}}List[Literal[{{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]]{{/required}}{{^required}}Optional[List[Literal[{{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]]]{{/required}} = Field( + {{#required}}...{{/required}}{{^required}}None{{/required}}, + description="{{description}}{{^description}}{{{name}}} of the {{classname}}{{/description}}" + ) + {{/isArray}} + {{/allowableValues}} + {{/isEnum}} + {{^isEnum}} {{name}}: {{{vendorExtensions.x-py-typing}}} + {{/isEnum}} {{/vars}} {{#isAdditionalPropertiesTrue}} additional_properties: Dict[str, Any] = {} @@ -76,18 +111,18 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{#isContainer}} {{#isArray}} for i in value: - if i not in set([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]): - raise ValueError("each list item must be one of ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})") + if i not in set([{{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]): + raise ValueError("each list item must be one of ({{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})") {{/isArray}} {{#isMap}} for i in value.values(): - if i not in set([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]): - raise ValueError("dict values must be one of enum values ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})") + if i not in set([{{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]): + raise ValueError("dict values must be one of enum values ({{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})") {{/isMap}} {{/isContainer}} {{^isContainer}} - if value not in set([{{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]): - raise ValueError("must be one of enum values ({{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})") + if value not in set([{{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]): + raise ValueError("must be one of enum values ({{#allowableValues}}{{#enumVars}}{{#isString}}{{{value}}}{{/isString}}{{^isString}}{{{value}}}{{/isString}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}})") {{/isContainer}} return value {{/isEnum}} @@ -121,278 +156,28 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} {{/discriminator}} {{/hasChildren}} - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[{{^hasChildren}}Self{{/hasChildren}}{{#hasChildren}}{{#discriminator}}Union[{{#mappedModels}}{{{modelName}}}{{^-last}}, {{/-last}}{{/mappedModels}}]{{/discriminator}}{{^discriminator}}Self{{/discriminator}}{{/hasChildren}}]: - """Create an instance of {{{classname}}} from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - {{#vendorExtensions.x-py-readonly}} - * OpenAPI `readOnly` fields are excluded. - {{/vendorExtensions.x-py-readonly}} - {{#isAdditionalPropertiesTrue}} - * Fields in `self.additional_properties` are added to the output dict. - {{/isAdditionalPropertiesTrue}} - """ - excluded_fields: Set[str] = set([ - {{#vendorExtensions.x-py-readonly}} - "{{{.}}}", - {{/vendorExtensions.x-py-readonly}} - {{#isAdditionalPropertiesTrue}} - "additional_properties", - {{/isAdditionalPropertiesTrue}} - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - {{#allVars}} - {{#isContainer}} - {{#isArray}} - {{#items.isArray}} - {{^items.items.isPrimitiveType}} - # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list of list) - _items = [] - if self.{{{name}}}: - for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}}: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_{{{name}}} if _inner_item is not None] - ) - _dict['{{{baseName}}}'] = _items - {{/items.items.isPrimitiveType}} - {{/items.isArray}} - {{^items.isArray}} - {{^items.isPrimitiveType}} - {{^items.isEnumOrRef}} - # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list) - _items = [] - if self.{{{name}}}: - for _item_{{{name}}} in self.{{{name}}}: - if _item_{{{name}}}: - _items.append(_item_{{{name}}}.to_dict()) - _dict['{{{baseName}}}'] = _items - {{/items.isEnumOrRef}} - {{/items.isPrimitiveType}} - {{/items.isArray}} - {{/isArray}} - {{#isMap}} - {{#items.isArray}} - {{^items.items.isPrimitiveType}} - # override the default output from pydantic by calling `to_dict()` of each value in {{{name}}} (dict of array) - _field_dict_of_array = {} - if self.{{{name}}}: - for _key_{{{name}}} in self.{{{name}}}: - if self.{{{name}}}[_key_{{{name}}}] is not None: - _field_dict_of_array[_key_{{{name}}}] = [ - _item.to_dict() for _item in self.{{{name}}}[_key_{{{name}}}] - ] - _dict['{{{baseName}}}'] = _field_dict_of_array - {{/items.items.isPrimitiveType}} - {{/items.isArray}} - {{^items.isArray}} - {{^items.isPrimitiveType}} - {{^items.isEnumOrRef}} - # override the default output from pydantic by calling `to_dict()` of each value in {{{name}}} (dict) - _field_dict = {} - if self.{{{name}}}: - for _key_{{{name}}} in self.{{{name}}}: - if self.{{{name}}}[_key_{{{name}}}]: - _field_dict[_key_{{{name}}}] = self.{{{name}}}[_key_{{{name}}}].to_dict() - _dict['{{{baseName}}}'] = _field_dict - {{/items.isEnumOrRef}} - {{/items.isPrimitiveType}} - {{/items.isArray}} - {{/isMap}} - {{/isContainer}} - {{^isContainer}} - {{^isPrimitiveType}} - {{^isEnumOrRef}} - # override the default output from pydantic by calling `to_dict()` of {{{name}}} - if self.{{{name}}}: - _dict['{{{baseName}}}'] = self.{{{name}}}.to_dict() - {{/isEnumOrRef}} - {{/isPrimitiveType}} - {{/isContainer}} - {{/allVars}} - {{#isAdditionalPropertiesTrue}} - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - {{/isAdditionalPropertiesTrue}} - {{#allVars}} - {{#isNullable}} - # set to None if {{{name}}} (nullable) is None - # and model_fields_set contains the field - if self.{{name}} is None and "{{{name}}}" in self.model_fields_set: - _dict['{{{baseName}}}'] = None - - {{/isNullable}} - {{/allVars}} - return _dict - - {{#hasChildren}} @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[{{#discriminator}}Union[{{#mappedModels}}{{{modelName}}}{{^-last}}, {{/-last}}{{/mappedModels}}]{{/discriminator}}{{^discriminator}}Self{{/discriminator}}]: - """Create an instance of {{{classname}}} from a dict""" - {{#discriminator}} - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - {{#mappedModels}} - if object_type == '{{{modelName}}}': - return import_module("{{packageName}}.models.{{model.classFilename}}").{{modelName}}.from_dict(obj) - {{/mappedModels}} + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - raise ValueError("{{{classname}}} failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) - {{/discriminator}} - {{/hasChildren}} - {{^hasChildren}} @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of {{{classname}}} from a dict""" - if obj is None: - return None + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - if not isinstance(obj, dict): - return cls.model_validate(obj) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return self.model_dump_json(by_alias=True, exclude_none=True) - {{#disallowAdditionalPropertiesIfNotPresent}} - {{^isAdditionalPropertiesTrue}} - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in {{classname}}) in the input: " + _key) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - {{/isAdditionalPropertiesTrue}} - {{/disallowAdditionalPropertiesIfNotPresent}} - _obj = cls.model_validate({ - {{#allVars}} - {{#isContainer}} - {{#isArray}} - {{#items.isArray}} - {{#items.items.isPrimitiveType}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} - {{/items.items.isPrimitiveType}} - {{^items.items.isPrimitiveType}} - "{{{baseName}}}": [ - [{{{items.items.dataType}}}.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["{{{baseName}}}"] - ] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} - {{/items.items.isPrimitiveType}} - {{/items.isArray}} - {{^items.isArray}} - {{^items.isPrimitiveType}} - {{#items.isEnumOrRef}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} - {{/items.isEnumOrRef}} - {{^items.isEnumOrRef}} - "{{{baseName}}}": [{{{items.dataType}}}.from_dict(_item) for _item in obj["{{{baseName}}}"]] if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} - {{/items.isEnumOrRef}} - {{/items.isPrimitiveType}} - {{#items.isPrimitiveType}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} - {{/items.isPrimitiveType}} - {{/items.isArray}} - {{/isArray}} - {{#isMap}} - {{^items.isPrimitiveType}} - {{^items.isEnumOrRef}} - {{#items.isContainer}} - {{#items.isMap}} - "{{{baseName}}}": dict( - (_k, dict( - (_ik, {{{items.items.dataType}}}.from_dict(_iv)) - for _ik, _iv in _v.items() - ) - if _v is not None - else None - ) - for _k, _v in obj.get("{{{baseName}}}").items() - ) - if obj.get("{{{baseName}}}") is not None - else None{{^-last}},{{/-last}} - {{/items.isMap}} - {{#items.isArray}} - "{{{baseName}}}": dict( - (_k, - [{{{items.items.dataType}}}.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("{{{baseName}}}", {}).items() - ){{^-last}},{{/-last}} - {{/items.isArray}} - {{/items.isContainer}} - {{^items.isContainer}} - "{{{baseName}}}": dict( - (_k, {{{items.dataType}}}.from_dict(_v)) - for _k, _v in obj["{{{baseName}}}"].items() - ) - if obj.get("{{{baseName}}}") is not None - else None{{^-last}},{{/-last}} - {{/items.isContainer}} - {{/items.isEnumOrRef}} - {{#items.isEnumOrRef}} - "{{{baseName}}}": dict((_k, _v) for _k, _v in obj.get("{{{baseName}}}").items()) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} - {{/items.isEnumOrRef}} - {{/items.isPrimitiveType}} - {{#items.isPrimitiveType}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} - {{/items.isPrimitiveType}} - {{/isMap}} - {{/isContainer}} - {{^isContainer}} - {{^isPrimitiveType}} - {{^isEnumOrRef}} - "{{{baseName}}}": {{{dataType}}}.from_dict(obj["{{{baseName}}}"]) if obj.get("{{{baseName}}}") is not None else None{{^-last}},{{/-last}} - {{/isEnumOrRef}} - {{#isEnumOrRef}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{#defaultValue}} if obj.get("{{baseName}}") is not None else {{{defaultValue}}}{{/defaultValue}}{{^-last}},{{/-last}} - {{/isEnumOrRef}} - {{/isPrimitiveType}} - {{#isPrimitiveType}} - {{#defaultValue}} - "{{{baseName}}}": obj.get("{{{baseName}}}") if obj.get("{{{baseName}}}") is not None else {{{defaultValue}}}{{^-last}},{{/-last}} - {{/defaultValue}} - {{^defaultValue}} - "{{{baseName}}}": obj.get("{{{baseName}}}"){{^-last}},{{/-last}} - {{/defaultValue}} - {{/isPrimitiveType}} - {{/isContainer}} - {{/allVars}} - }) - {{#isAdditionalPropertiesTrue}} - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - {{/isAdditionalPropertiesTrue}} - return _obj - {{/hasChildren}} {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} diff --git a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache index 07a4d93f9ddf..03f0766ea3e0 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -7,198 +7,56 @@ import pprint {{#vendorExtensions.x-py-model-imports}} {{{.}}} {{/vendorExtensions.x-py-model-imports}} -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] -class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}): +class {{classname}}(RootModel[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]]): """ {{{description}}}{{^description}}{{{classname}}}{{/description}} """ -{{#composedSchemas.oneOf}} - # data type: {{{dataType}}} - {{vendorExtensions.x-py-name}}: {{{vendorExtensions.x-py-typing}}} -{{/composedSchemas.oneOf}} - actual_instance: Optional[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]] = None - one_of_schemas: Set[str] = { {{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}} } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[{{#oneOf}}{{.}}{{^-last}}, {{/-last}}{{/oneOf}}{{#isNullable}}, None{{/isNullable}}] = Field( + {{#isNullable}}None{{/isNullable}}{{^isNullable}}...{{/isNullable}}{{#discriminator}}, discriminator="{{discriminatorName}}"{{/discriminator}} ) -{{#discriminator}} - - discriminator_value_class_map: Dict[str, str] = { -{{#children}} - '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': '{{{classname}}}'{{^-last}},{{/-last}} -{{/children}} - } -{{/discriminator}} + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) + if name in self.__dict__: + return super().__getattribute__(name) - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - {{#isNullable}} - if v is None: - return v + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) - {{/isNullable}} - instance = {{{classname}}}.model_construct() - error_messages = [] - match = 0 - {{#composedSchemas.oneOf}} - # validate data type: {{{dataType}}} - {{#isContainer}} - try: - instance.{{vendorExtensions.x-py-name}} = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isContainer}} - {{^isContainer}} - {{#isPrimitiveType}} - try: - instance.{{vendorExtensions.x-py-name}} = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isPrimitiveType}} - {{^isPrimitiveType}} - if not isinstance(v, {{{dataType}}}): - error_messages.append(f"Error! Input type `{type(v)}` is not `{{{dataType}}}`") - else: - match += 1 - {{/isPrimitiveType}} - {{/isContainer}} - {{/composedSchemas.oneOf}} - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in {{{classname}}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in {{{classname}}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: " + ", ".join(error_messages)) - else: - return v + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - {{#isNullable}} - def from_json(cls, json_str: Optional[str]) -> Self: - {{/isNullable}} - {{^isNullable}} def from_json(cls, json_str: str) -> Self: - {{/isNullable}} """Returns the object represented by the json string""" - instance = cls.model_construct() - {{#isNullable}} - if json_str is None: - return instance - - {{/isNullable}} - error_messages = [] - match = 0 - - {{#useOneOfDiscriminatorLookup}} - {{#discriminator}} - {{#mappedModels}} - {{#-first}} - # use oneOf discriminator to lookup the data type - _data_type = json.loads(json_str).get("{{{propertyBaseName}}}") - if not _data_type: - raise ValueError("Failed to lookup data type from the field `{{{propertyBaseName}}}` in the input.") - - {{/-first}} - # check if data type is `{{{modelName}}}` - if _data_type == "{{{mappingName}}}": - instance.actual_instance = {{{modelName}}}.from_json(json_str) - return instance - - {{/mappedModels}} - {{/discriminator}} - {{/useOneOfDiscriminatorLookup}} - {{#composedSchemas.oneOf}} - {{#isContainer}} - # deserialize data into {{{dataType}}} - try: - # validation - instance.{{vendorExtensions.x-py-name}} = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.{{vendorExtensions.x-py-name}} - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isContainer}} - {{^isContainer}} - {{#isPrimitiveType}} - # deserialize data into {{{dataType}}} - try: - # validation - instance.{{vendorExtensions.x-py-name}} = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.{{vendorExtensions.x-py-name}} - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isPrimitiveType}} - {{^isPrimitiveType}} - # deserialize data into {{{dataType}}} - try: - instance.actual_instance = {{{dataType}}}.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - {{/isPrimitiveType}} - {{/isContainer}} - {{/composedSchemas.oneOf}} - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into {{{classname}}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into {{{classname}}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} diff --git a/samples/client/others/c/bearerAuth/src/list.c b/samples/client/others/c/bearerAuth/src/list.c index 7053ff122dfc..e69de29bb2d1 100644 --- a/samples/client/others/c/bearerAuth/src/list.c +++ b/samples/client/others/c/bearerAuth/src/list.c @@ -1,200 +0,0 @@ -#include -#include -#include -#include - -#include "../include/list.h" -static listEntry_t *listEntry_create(void *data) { - listEntry_t *createdListEntry = malloc(sizeof(listEntry_t)); - if(createdListEntry == NULL) { - // TODO Malloc Failure - return NULL; - } - createdListEntry->data = data; - - return createdListEntry; -} - -void listEntry_free(listEntry_t *listEntry, void *additionalData) { - free(listEntry); -} - -void listEntry_printAsInt(listEntry_t *listEntry, void *additionalData) { - printf("%i\n", *(int *)listEntry->data); -} - -list_t *list_createList() { - list_t *createdList = malloc(sizeof(list_t)); - if(createdList == NULL) { - // TODO Malloc Failure - return NULL; - } - createdList->firstEntry = NULL; - createdList->lastEntry = NULL; - createdList->count = 0; - - return createdList; -} - -void list_iterateThroughListForward(list_t *list, - void (*operationToPerform)( - listEntry_t *, - void *callbackFunctionUsedData), - void *additionalDataNeededForCallbackFunction) -{ - listEntry_t *currentListEntry = list->firstEntry; - listEntry_t *nextListEntry; - - if(currentListEntry == NULL) { - return; - } - - nextListEntry = currentListEntry->nextListEntry; - - operationToPerform(currentListEntry, - additionalDataNeededForCallbackFunction); - currentListEntry = nextListEntry; - - while(currentListEntry != NULL) { - nextListEntry = currentListEntry->nextListEntry; - operationToPerform(currentListEntry, - additionalDataNeededForCallbackFunction); - currentListEntry = nextListEntry; - } -} - -void list_iterateThroughListBackward(list_t *list, - void (*operationToPerform)( - listEntry_t *, - void *callbackFunctionUsedData), - void *additionalDataNeededForCallbackFunction) -{ - listEntry_t *currentListEntry = list->lastEntry; - listEntry_t *nextListEntry = currentListEntry->prevListEntry; - - if(currentListEntry == NULL) { - return; - } - - operationToPerform(currentListEntry, - additionalDataNeededForCallbackFunction); - currentListEntry = nextListEntry; - - while(currentListEntry != NULL) { - nextListEntry = currentListEntry->prevListEntry; - operationToPerform(currentListEntry, - additionalDataNeededForCallbackFunction); - currentListEntry = nextListEntry; - } -} - -void list_freeList(list_t *list) { - if(list){ - list_iterateThroughListForward(list, listEntry_free, NULL); - free(list); - } -} - -void list_addElement(list_t *list, void *dataToAddInList) { - listEntry_t *newListEntry = listEntry_create(dataToAddInList); - if(newListEntry == NULL) { - // TODO Malloc Failure - return; - } - if(list->firstEntry == NULL) { - list->firstEntry = newListEntry; - list->lastEntry = newListEntry; - - newListEntry->prevListEntry = NULL; - newListEntry->nextListEntry = NULL; - - list->count++; - - return; - } - - list->lastEntry->nextListEntry = newListEntry; - newListEntry->prevListEntry = list->lastEntry; - newListEntry->nextListEntry = NULL; - list->lastEntry = newListEntry; - - list->count++; -} - -void list_removeElement(list_t *list, listEntry_t *elementToRemove) { - listEntry_t *elementBeforeElementToRemove = - elementToRemove->prevListEntry; - listEntry_t *elementAfterElementToRemove = - elementToRemove->nextListEntry; - - if(elementBeforeElementToRemove != NULL) { - elementBeforeElementToRemove->nextListEntry = - elementAfterElementToRemove; - } else { - list->firstEntry = elementAfterElementToRemove; - } - - if(elementAfterElementToRemove != NULL) { - elementAfterElementToRemove->prevListEntry = - elementBeforeElementToRemove; - } else { - list->lastEntry = elementBeforeElementToRemove; - } - - listEntry_free(elementToRemove, NULL); - - list->count--; -} - -listEntry_t *list_getElementAt(list_t *list, long indexOfElement) { - listEntry_t *currentListEntry; - - if((list->count / 2) > indexOfElement) { - currentListEntry = list->firstEntry; - - for(int i = 0; i < indexOfElement; i++) { - currentListEntry = currentListEntry->nextListEntry; - } - - return currentListEntry; - } else { - currentListEntry = list->lastEntry; - - for(int i = 1; i < (list->count - indexOfElement); i++) { - currentListEntry = currentListEntry->prevListEntry; - } - - return currentListEntry; - } -} - -char* findStrInStrList(list_t *strList, const char *str) -{ - if (!strList || !str) { - return NULL; - } - - listEntry_t* listEntry = NULL; - list_ForEach(listEntry, strList) { - if (strstr(listEntry->data, str) != NULL) { - return listEntry->data; - } - } - - return NULL; -} - -void clear_and_free_string_list(list_t *list) -{ - if (!list) { - return; - } - - listEntry_t *listEntry = NULL; - list_ForEach(listEntry, list) { - char *list_item = listEntry->data; - free(list_item); - list_item = NULL; - } - list_freeList(list); -} diff --git a/samples/client/petstore/apex/config/project-scratch-def.json b/samples/client/petstore/apex/config/project-scratch-def.json index 36aace552669..e69de29bb2d1 100644 --- a/samples/client/petstore/apex/config/project-scratch-def.json +++ b/samples/client/petstore/apex/config/project-scratch-def.json @@ -1,8 +0,0 @@ -{ - "orgName": "muenzpraeger - René Winkelmeyer", - "edition": "Developer", - "orgPreferences": { - "enabled": ["S1DesktopEnabled"], - "disabled": ["S1EncryptedStoragePref2"] - } -} diff --git a/samples/client/petstore/bash/docs/EnumTest.md b/samples/client/petstore/bash/docs/EnumTest.md index 30b30efa7307..e69de29bb2d1 100644 --- a/samples/client/petstore/bash/docs/EnumTest.md +++ b/samples/client/petstore/bash/docs/EnumTest.md @@ -1,14 +0,0 @@ -# Enum_Test - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**enumUnderscorestring** | **string** | | [optional] [default to null] -**enumUnderscorestringUnderscorerequired** | **string** | | [default to null] -**enumUnderscoreinteger** | **integer** | | [optional] [default to null] -**enumUnderscorenumber** | **float** | | [optional] [default to null] -**outerEnum** | [**OuterEnum**](OuterEnum.md) | | [optional] [default to null] - -[[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/c-useJsonUnformatted/model/model_with_set_propertes.h b/samples/client/petstore/c-useJsonUnformatted/model/model_with_set_propertes.h index aa82893b94bb..e69de29bb2d1 100644 --- a/samples/client/petstore/c-useJsonUnformatted/model/model_with_set_propertes.h +++ b/samples/client/petstore/c-useJsonUnformatted/model/model_with_set_propertes.h @@ -1,41 +0,0 @@ -/* - * model_with_set_propertes.h - * - * to test set properties - */ - -#ifndef _model_with_set_propertes_H_ -#define _model_with_set_propertes_H_ - -#include -#include "../external/cJSON.h" -#include "../include/list.h" -#include "../include/keyValuePair.h" -#include "../include/binary.h" - -typedef struct model_with_set_propertes_t model_with_set_propertes_t; - -#include "tag.h" - - - -typedef struct model_with_set_propertes_t { - list_t *tag_set; //nonprimitive container - list_t *string_set; //primitive container - - int _library_owned; // Is the library responsible for freeing this object? -} model_with_set_propertes_t; - -__attribute__((deprecated)) model_with_set_propertes_t *model_with_set_propertes_create( - list_t *tag_set, - list_t *string_set -); - -void model_with_set_propertes_free(model_with_set_propertes_t *model_with_set_propertes); - -model_with_set_propertes_t *model_with_set_propertes_parseFromJSON(cJSON *model_with_set_propertesJSON); - -cJSON *model_with_set_propertes_convertToJSON(model_with_set_propertes_t *model_with_set_propertes); - -#endif /* _model_with_set_propertes_H_ */ - diff --git a/samples/client/petstore/c/model/api_response.c b/samples/client/petstore/c/model/api_response.c index d0169c84f5b2..e69de29bb2d1 100644 --- a/samples/client/petstore/c/model/api_response.c +++ b/samples/client/petstore/c/model/api_response.c @@ -1,142 +0,0 @@ -#include -#include -#include -#include "api_response.h" - - - -static api_response_t *api_response_create_internal( - int code, - char *type, - char *message - ) { - api_response_t *api_response_local_var = malloc(sizeof(api_response_t)); - if (!api_response_local_var) { - return NULL; - } - api_response_local_var->code = code; - api_response_local_var->type = type; - api_response_local_var->message = message; - - api_response_local_var->_library_owned = 1; - return api_response_local_var; -} - -__attribute__((deprecated)) api_response_t *api_response_create( - int code, - char *type, - char *message - ) { - return api_response_create_internal ( - code, - type, - message - ); -} - -void api_response_free(api_response_t *api_response) { - if(NULL == api_response){ - return ; - } - if(api_response->_library_owned != 1){ - fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "api_response_free"); - return ; - } - listEntry_t *listEntry; - if (api_response->type) { - free(api_response->type); - api_response->type = NULL; - } - if (api_response->message) { - free(api_response->message); - api_response->message = NULL; - } - free(api_response); -} - -cJSON *api_response_convertToJSON(api_response_t *api_response) { - cJSON *item = cJSON_CreateObject(); - - // api_response->code - if(api_response->code) { - if(cJSON_AddNumberToObject(item, "code", api_response->code) == NULL) { - goto fail; //Numeric - } - } - - - // api_response->type - if(api_response->type) { - if(cJSON_AddStringToObject(item, "type", api_response->type) == NULL) { - goto fail; //String - } - } - - - // api_response->message - if(api_response->message) { - if(cJSON_AddStringToObject(item, "message", api_response->message) == NULL) { - goto fail; //String - } - } - - return item; -fail: - if (item) { - cJSON_Delete(item); - } - return NULL; -} - -api_response_t *api_response_parseFromJSON(cJSON *api_responseJSON){ - - api_response_t *api_response_local_var = NULL; - - // api_response->code - cJSON *code = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "code"); - if (cJSON_IsNull(code)) { - code = NULL; - } - if (code) { - if(!cJSON_IsNumber(code)) - { - goto end; //Numeric - } - } - - // api_response->type - cJSON *type = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "type"); - if (cJSON_IsNull(type)) { - type = NULL; - } - if (type) { - if(!cJSON_IsString(type) && !cJSON_IsNull(type)) - { - goto end; //String - } - } - - // api_response->message - cJSON *message = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "message"); - if (cJSON_IsNull(message)) { - message = NULL; - } - if (message) { - if(!cJSON_IsString(message) && !cJSON_IsNull(message)) - { - goto end; //String - } - } - - - api_response_local_var = api_response_create_internal ( - code ? code->valuedouble : 0, - type && !cJSON_IsNull(type) ? strdup(type->valuestring) : NULL, - message && !cJSON_IsNull(message) ? strdup(message->valuestring) : NULL - ); - - return api_response_local_var; -end: - return NULL; - -} diff --git a/samples/client/petstore/cpp-oatpp/model/Tag.hpp b/samples/client/petstore/cpp-oatpp/model/Tag.hpp index befd6854d51e..e69de29bb2d1 100644 --- a/samples/client/petstore/cpp-oatpp/model/Tag.hpp +++ b/samples/client/petstore/cpp-oatpp/model/Tag.hpp @@ -1,51 +0,0 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* 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. -*/ -/* - * Tag.h - * - * A tag for a pet - */ - -#ifndef Tag_H_ -#define Tag_H_ - - -#include "oatpp/core/macro/codegen.hpp" -#include "oatpp/core/Types.hpp" - -namespace org::openapitools::client::model -{ - -/* Begin DTO code-generation */ -#include OATPP_CODEGEN_BEGIN(DTO) - -/** - * Message Data-Transfer-Object - */ -class Tag : public oatpp::DTO { - - DTO_INIT(Tag, DTO /* Extends */) - - DTO_FIELD(oatpp::Int64, id); - DTO_FIELD(oatpp::Boolean, idIsSet); - DTO_FIELD(oatpp::String, name); - DTO_FIELD(oatpp::Boolean, nameIsSet); - -}; - -/* End DTO code-generation */ -#include OATPP_CODEGEN_END(DTO) - - -} // namespace org::openapitools::client::model - -#endif /* Tag_H_ */ diff --git a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/appsettings.json index def9159a7d94..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/appsettings.json @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/appsettings.json index def9159a7d94..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/appsettings.json @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/appsettings.json index def9159a7d94..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/appsettings.json @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json index def9159a7d94..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile index 7184e1ece4d0..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile +++ b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile @@ -1,32 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -# Container we use for final publish -FROM mcr.microsoft.com/dotnet/core/aspnet:6.0-buster-slim AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -# Build container -FROM mcr.microsoft.com/dotnet/core/sdk:6.0-buster AS build - -# Copy the code into the container -WORKDIR /src -COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] - -# NuGet restore -RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" -COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] - -# Build the API -WORKDIR "Org.OpenAPITools" -RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build - -# Publish it -FROM build AS publish -RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish - -# Make the final image for publishing -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/appsettings.json index def9159a7d94..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/appsettings.json @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs index 122f58cabe4a..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs +++ b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs @@ -1,61 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System; -using System.Linq; -using System.Text; - -namespace Org.OpenAPITools.OpenApi -{ - /// - /// Replacement utilities from Swashbuckle.AspNetCore.SwaggerGen which are not in 5.x - /// - public static class TypeExtensions - { - /// - /// Produce a friendly name for the type which is unique. - /// - /// - /// - public static string FriendlyId(this Type type, bool fullyQualified = false) - { - var typeName = fullyQualified - ? type.FullNameSansTypeParameters().Replace("+", ".") - : type.Name; - - if (type.IsGenericType) - { - var genericArgumentIds = type.GetGenericArguments() - .Select(t => t.FriendlyId(fullyQualified)) - .ToArray(); - - return new StringBuilder(typeName) - .Replace($"`{genericArgumentIds.Count()}", string.Empty) - .Append($"[{string.Join(",", genericArgumentIds).TrimEnd(',')}]") - .ToString(); - } - - return typeName; - } - - /// - /// Determine the fully qualified type name without type parameters. - /// - /// - public static string FullNameSansTypeParameters(this Type type) - { - var fullName = type.FullName; - if (string.IsNullOrEmpty(fullName)) - fullName = type.Name; - var chopIndex = fullName.IndexOf("[[", StringComparison.Ordinal); - return (chopIndex == -1) ? fullName : fullName.Substring(0, chopIndex); - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec index b1d83a359618..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec +++ b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec @@ -1,20 +0,0 @@ - - - - $id$ - 1.0.0 - OpenAPI Library - OpenAPI - OpenAPI - https://www.apache.org/licenses/LICENSE-2.0.html - - false - A library generated from a OpenAPI doc - Summary of changes made in this release of the package. - No Copyright - Org.OpenAPITools - - diff --git a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/appsettings.json index def9159a7d94..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/appsettings.json @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile index c24f45dbc5a4..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile @@ -1,32 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -# Container we use for final publish -FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -# Build container -FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build - -# Copy the code into the container -WORKDIR /src -COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] - -# NuGet restore -RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" -COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] - -# Build the API -WORKDIR "Org.OpenAPITools" -RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build - -# Publish it -FROM build AS publish -RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish - -# Make the final image for publishing -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile index c24f45dbc5a4..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile @@ -1,32 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -# Container we use for final publish -FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -# Build container -FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build - -# Copy the code into the container -WORKDIR /src -COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] - -# NuGet restore -RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" -COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] - -# Build the API -WORKDIR "Org.OpenAPITools" -RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build - -# Publish it -FROM build AS publish -RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish - -# Make the final image for publishing -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json index def9159a7d94..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj index 99b5e849d995..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -1,27 +0,0 @@ - - - A library generated from a OpenAPI doc - No Copyright - OpenAPI - net8.0 - true - true - 1.0.0 - Org.OpenAPITools - Org.OpenAPITools - cb87e868-8646-48ef-9bb6-344b537d0d37 - Linux - ..\.. - - - - - - - - - - - - - diff --git a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Dockerfile index c24f45dbc5a4..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Dockerfile +++ b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Dockerfile @@ -1,32 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -# Container we use for final publish -FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -# Build container -FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build - -# Copy the code into the container -WORKDIR /src -COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] - -# NuGet restore -RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" -COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] - -# Build the API -WORKDIR "Org.OpenAPITools" -RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build - -# Publish it -FROM build AS publish -RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish - -# Make the final image for publishing -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec index b1d83a359618..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec @@ -1,20 +0,0 @@ - - - - $id$ - 1.0.0 - OpenAPI Library - OpenAPI - OpenAPI - https://www.apache.org/licenses/LICENSE-2.0.html - - false - A library generated from a OpenAPI doc - Summary of changes made in this release of the package. - No Copyright - Org.OpenAPITools - - diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json index def9159a7d94..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning" - } - }, - "AllowedHosts": "*" -} diff --git a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Properties/launchSettings.json b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Properties/launchSettings.json index 1b527df2c2b3..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Properties/launchSettings.json +++ b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Properties/launchSettings.json @@ -1,30 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:61788", - "sslPort": 44301 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "api/values", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "WebApplication1": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "api/values", - "applicationUrl": "https://localhost:5001;http://localhost:5000", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} \ No newline at end of file diff --git a/samples/server/petstore/cpp-oatpp/model/Tag.hpp b/samples/server/petstore/cpp-oatpp/model/Tag.hpp index f7941e8e3911..e69de29bb2d1 100644 --- a/samples/server/petstore/cpp-oatpp/model/Tag.hpp +++ b/samples/server/petstore/cpp-oatpp/model/Tag.hpp @@ -1,51 +0,0 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* 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. -*/ -/* - * Tag.h - * - * A tag for a pet - */ - -#ifndef Tag_H_ -#define Tag_H_ - - -#include "oatpp/core/macro/codegen.hpp" -#include "oatpp/core/Types.hpp" - -namespace org::openapitools::server::model -{ - -/* Begin DTO code-generation */ -#include OATPP_CODEGEN_BEGIN(DTO) - -/** - * Message Data-Transfer-Object - */ -class Tag : public oatpp::DTO { - - DTO_INIT(Tag, DTO /* Extends */) - - DTO_FIELD(oatpp::Int64, id); - DTO_FIELD(oatpp::Boolean, idIsSet); - DTO_FIELD(oatpp::String, name); - DTO_FIELD(oatpp::Boolean, nameIsSet); - -}; - -/* End DTO code-generation */ -#include OATPP_CODEGEN_END(DTO) - - -} // namespace org::openapitools::server::model - -#endif /* Tag_H_ */ diff --git a/samples/server/petstore/cpp-pistache-everything/model/Category.cpp b/samples/server/petstore/cpp-pistache-everything/model/Category.cpp index e69de29bb2d1..bd76b4cd6630 100644 --- a/samples/server/petstore/cpp-pistache-everything/model/Category.cpp +++ b/samples/server/petstore/cpp-pistache-everything/model/Category.cpp @@ -0,0 +1,144 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* 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. +*/ + + +#include "Category.h" +#include "Helpers.h" + +#include + +namespace org::openapitools::server::model +{ + +Category::Category() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Name = ""; + m_NameIsSet = false; + +} + +void Category::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool Category::validate(std::stringstream& msg) const +{ + return validate(msg, ""); +} + +bool Category::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Category" : pathPrefix; + + + if (nameIsSet()) + { + const std::string& value = m_Name; + const std::string currentValuePath = _pathPrefix + ".name"; + + + + } + + return success; +} + +bool Category::operator==(const Category& rhs) const +{ + return + + + + ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && + + + ((!nameIsSet() && !rhs.nameIsSet()) || (nameIsSet() && rhs.nameIsSet() && getName() == rhs.getName())) + + ; +} + +bool Category::operator!=(const Category& rhs) const +{ + return !(*this == rhs); +} + +void to_json(nlohmann::json& j, const Category& o) +{ + j = nlohmann::json::object(); + if(o.idIsSet()) + j["id"] = o.m_Id; + if(o.nameIsSet()) + j["name"] = o.m_Name; + +} + +void from_json(const nlohmann::json& j, Category& o) +{ + if(j.find("id") != j.end()) + { + j.at("id").get_to(o.m_Id); + o.m_IdIsSet = true; + } + if(j.find("name") != j.end()) + { + j.at("name").get_to(o.m_Name); + o.m_NameIsSet = true; + } + +} + +int64_t Category::getId() const +{ + return m_Id; +} +void Category::setId(int64_t const value) +{ + m_Id = value; + m_IdIsSet = true; +} +bool Category::idIsSet() const +{ + return m_IdIsSet; +} +void Category::unsetId() +{ + m_IdIsSet = false; +} +std::string Category::getName() const +{ + return m_Name; +} +void Category::setName(std::string const& value) +{ + m_Name = value; + m_NameIsSet = true; +} +bool Category::nameIsSet() const +{ + return m_NameIsSet; +} +void Category::unsetName() +{ + m_NameIsSet = false; +} + + +} // namespace org::openapitools::server::model + diff --git a/samples/server/petstore/cpp-pistache-everything/model/Order.h b/samples/server/petstore/cpp-pistache-everything/model/Order.h index 78a6c8805bbe..e69de29bb2d1 100644 --- a/samples/server/petstore/cpp-pistache-everything/model/Order.h +++ b/samples/server/petstore/cpp-pistache-everything/model/Order.h @@ -1,124 +0,0 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* 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. -*/ -/* - * Order.h - * - * An order for a pets from the pet store - */ - -#ifndef Order_H_ -#define Order_H_ - - -#include -#include - -namespace org::openapitools::server::model -{ - -/// -/// An order for a pets from the pet store -/// -class Order -{ -public: - Order(); - virtual ~Order() = default; - - - /// - /// Validate the current data in the model. Throws a ValidationException on failure. - /// - void validate() const; - - /// - /// Validate the current data in the model. Returns false on error and writes an error - /// message into the given stringstream. - /// - bool validate(std::stringstream& msg) const; - - /// - /// Helper overload for validate. Used when one model stores another model and calls it's validate. - /// Not meant to be called outside that case. - /// - bool validate(std::stringstream& msg, const std::string& pathPrefix) const; - - bool operator==(const Order& rhs) const; - bool operator!=(const Order& rhs) const; - - ///////////////////////////////////////////// - /// Order members - - /// - /// - /// - int64_t getId() const; - void setId(int64_t const value); - bool idIsSet() const; - void unsetId(); - /// - /// - /// - int64_t getPetId() const; - void setPetId(int64_t const value); - bool petIdIsSet() const; - void unsetPetId(); - /// - /// - /// - int32_t getQuantity() const; - void setQuantity(int32_t const value); - bool quantityIsSet() const; - void unsetQuantity(); - /// - /// - /// - std::string getShipDate() const; - void setShipDate(std::string const& value); - bool shipDateIsSet() const; - void unsetShipDate(); - /// - /// Order Status - /// - std::string getStatus() const; - void setStatus(std::string const& value); - bool statusIsSet() const; - void unsetStatus(); - /// - /// - /// - bool isComplete() const; - void setComplete(bool const value); - bool completeIsSet() const; - void unsetComplete(); - - friend void to_json(nlohmann::json& j, const Order& o); - friend void from_json(const nlohmann::json& j, Order& o); -protected: - int64_t m_Id; - bool m_IdIsSet; - int64_t m_PetId; - bool m_PetIdIsSet; - int32_t m_Quantity; - bool m_QuantityIsSet; - std::string m_ShipDate; - bool m_ShipDateIsSet; - std::string m_Status; - bool m_StatusIsSet; - bool m_Complete; - bool m_CompleteIsSet; - -}; - -} // namespace org::openapitools::server::model - -#endif /* Order_H_ */ diff --git a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.h b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.h index df53df3c2be7..e69de29bb2d1 100644 --- a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.h +++ b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.h @@ -1,77 +0,0 @@ -/** -* Test swagger file -* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) -* -* 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. -*/ -/* - * OuterType.h - * - * - */ - -#ifndef OuterType_H_ -#define OuterType_H_ - - -#include "MiddleType.h" -#include - -namespace org::openapitools::server::model -{ - -/// -/// -/// -class OuterType -{ -public: - OuterType(); - virtual ~OuterType() = default; - - - /// - /// Validate the current data in the model. Throws a ValidationException on failure. - /// - void validate() const; - - /// - /// Validate the current data in the model. Returns false on error and writes an error - /// message into the given stringstream. - /// - bool validate(std::stringstream& msg) const; - - /// - /// Helper overload for validate. Used when one model stores another model and calls it's validate. - /// Not meant to be called outside that case. - /// - bool validate(std::stringstream& msg, const std::string& pathPrefix) const; - - bool operator==(const OuterType& rhs) const; - bool operator!=(const OuterType& rhs) const; - - ///////////////////////////////////////////// - /// OuterType members - - /// - /// - /// - org::openapitools::server::model::MiddleType getMiddle() const; - void setMiddle(org::openapitools::server::model::MiddleType const& value); - - friend void to_json(nlohmann::json& j, const OuterType& o); - friend void from_json(const nlohmann::json& j, OuterType& o); -protected: - org::openapitools::server::model::MiddleType m_Middle; - - -}; - -} // namespace org::openapitools::server::model - -#endif /* OuterType_H_ */ From 294b05d2ff4e38ad50897fb44a80a2a6f1af9f53 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Thu, 12 Feb 2026 15:09:24 +0100 Subject: [PATCH 03/13] rebased --- .../c/bearerAuth/include/keyValuePair.h | 17 + .../client/others/c/bearerAuth/model/object.c | 51 - samples/client/others/c/bearerAuth/src/list.c | 200 +++ .../apex/config/project-scratch-def.json | 8 + samples/client/petstore/bash/docs/EnumTest.md | 14 + samples/client/petstore/bash/docs/MapTest.md | 13 - .../model/model_with_set_propertes.h | 41 + .../c-useJsonUnformatted/model/order.c | 233 ++++ .../petstore/c-useJsonUnformatted/model/pet.c | 335 ----- .../client/petstore/c/model/api_response.c | 142 ++ samples/client/petstore/c/model/category.c | 113 -- samples/client/petstore/c/model/category.h | 40 + .../petstore/cpp-oatpp/api/StoreApi.hpp | 77 -- .../client/petstore/cpp-oatpp/model/Tag.hpp | 51 + .../client/PFXApiResponse.cpp | 160 --- .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/Program.cs | 33 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/Program.cs | 33 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../Filters/BasePathFilter.cs | 60 - .../src/Org.OpenAPITools/Program.cs | 33 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/Program.cs | 33 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../src/Org.OpenAPITools/Dockerfile | 32 + .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/Program.cs | 33 + .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/appsettings.json | 8 + .../OpenApi/TypeExtensions.cs | 61 + .../src/Org.OpenAPITools/Program.cs | 33 + .../wwwroot/openapi-original.json | 1203 ----------------- .../Formatters/InputFormatterStream.cs | 45 + .../Org.OpenAPITools/Org.OpenAPITools.nuspec | 20 + .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/Program.cs | 33 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../src/Org.OpenAPITools/Dockerfile | 32 + .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/Startup.cs | 150 ++ .../src/Org.OpenAPITools/Dockerfile | 32 + .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/Program.cs | 33 + .../src/Org.OpenAPITools/Program.cs | 33 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../wwwroot/openapi-original.json | 1203 ----------------- .../Org.OpenAPITools/Org.OpenAPITools.csproj | 27 + .../src/Org.OpenAPITools/Program.cs | 33 + .../wwwroot/openapi-original.json | 1203 ----------------- .../src/Org.OpenAPITools/Dockerfile | 32 + .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/Program.cs | 33 + .../Formatters/InputFormatterStream.cs | 45 + .../Org.OpenAPITools/Org.OpenAPITools.nuspec | 20 + .../GeneratePathParamsValidationFilter.cs | 107 -- .../src/Org.OpenAPITools/Program.cs | 33 + .../src/Org.OpenAPITools/appsettings.json | 8 + .../Properties/launchSettings.json | 30 + .../wwwroot/openapi-original.json | 1021 -------------- .../server/petstore/cpp-oatpp/model/Order.hpp | 59 - .../cpp-pistache-everything/model/Order.cpp | 251 ---- .../cpp-pistache-everything/model/Order.h | 124 ++ .../api/StoreApi.cpp | 103 -- .../model/OuterType.cpp | 94 ++ .../model/OuterType.h | 77 ++ .../petstore/cpp-pistache/model/Category.cpp | 135 -- 69 files changed, 2027 insertions(+), 7057 deletions(-) diff --git a/samples/client/others/c/bearerAuth/include/keyValuePair.h b/samples/client/others/c/bearerAuth/include/keyValuePair.h index e69de29bb2d1..cb839f29cdcf 100644 --- a/samples/client/others/c/bearerAuth/include/keyValuePair.h +++ b/samples/client/others/c/bearerAuth/include/keyValuePair.h @@ -0,0 +1,17 @@ +#ifndef _keyValuePair_H_ +#define _keyValuePair_H_ + +#include + +typedef struct keyValuePair_t { + char* key; + void* value; +} keyValuePair_t; + +keyValuePair_t *keyValuePair_create(char *key, void *value); + +keyValuePair_t* keyValuePair_create_allocate(char* key, double value); + +void keyValuePair_free(keyValuePair_t *keyValuePair); + +#endif /* _keyValuePair_H_ */ \ No newline at end of file diff --git a/samples/client/others/c/bearerAuth/model/object.c b/samples/client/others/c/bearerAuth/model/object.c index ff293bcdac85..e69de29bb2d1 100644 --- a/samples/client/others/c/bearerAuth/model/object.c +++ b/samples/client/others/c/bearerAuth/model/object.c @@ -1,51 +0,0 @@ -#include -#include -#include -#include "object.h" - -object_t *object_create() { - object_t *object = calloc(1, sizeof(object_t)); - - return object; -} - -void object_free(object_t *object) { - if (!object) { - return ; - } - - if (object->temporary) { - free(object->temporary); - object->temporary = NULL; - } - - free (object); -} - -cJSON *object_convertToJSON(object_t *object) { - if (!object) { - return NULL; - } - - if (!object->temporary) { - return cJSON_Parse("null"); - } - - return cJSON_Parse(object->temporary); -} - -object_t *object_parseFromJSON(cJSON *json){ - if (!json) { - goto end; - } - - object_t *object = object_create(); - if (!object) { - goto end; - } - object->temporary = cJSON_Print(json); - return object; - -end: - return NULL; -} diff --git a/samples/client/others/c/bearerAuth/src/list.c b/samples/client/others/c/bearerAuth/src/list.c index e69de29bb2d1..7053ff122dfc 100644 --- a/samples/client/others/c/bearerAuth/src/list.c +++ b/samples/client/others/c/bearerAuth/src/list.c @@ -0,0 +1,200 @@ +#include +#include +#include +#include + +#include "../include/list.h" +static listEntry_t *listEntry_create(void *data) { + listEntry_t *createdListEntry = malloc(sizeof(listEntry_t)); + if(createdListEntry == NULL) { + // TODO Malloc Failure + return NULL; + } + createdListEntry->data = data; + + return createdListEntry; +} + +void listEntry_free(listEntry_t *listEntry, void *additionalData) { + free(listEntry); +} + +void listEntry_printAsInt(listEntry_t *listEntry, void *additionalData) { + printf("%i\n", *(int *)listEntry->data); +} + +list_t *list_createList() { + list_t *createdList = malloc(sizeof(list_t)); + if(createdList == NULL) { + // TODO Malloc Failure + return NULL; + } + createdList->firstEntry = NULL; + createdList->lastEntry = NULL; + createdList->count = 0; + + return createdList; +} + +void list_iterateThroughListForward(list_t *list, + void (*operationToPerform)( + listEntry_t *, + void *callbackFunctionUsedData), + void *additionalDataNeededForCallbackFunction) +{ + listEntry_t *currentListEntry = list->firstEntry; + listEntry_t *nextListEntry; + + if(currentListEntry == NULL) { + return; + } + + nextListEntry = currentListEntry->nextListEntry; + + operationToPerform(currentListEntry, + additionalDataNeededForCallbackFunction); + currentListEntry = nextListEntry; + + while(currentListEntry != NULL) { + nextListEntry = currentListEntry->nextListEntry; + operationToPerform(currentListEntry, + additionalDataNeededForCallbackFunction); + currentListEntry = nextListEntry; + } +} + +void list_iterateThroughListBackward(list_t *list, + void (*operationToPerform)( + listEntry_t *, + void *callbackFunctionUsedData), + void *additionalDataNeededForCallbackFunction) +{ + listEntry_t *currentListEntry = list->lastEntry; + listEntry_t *nextListEntry = currentListEntry->prevListEntry; + + if(currentListEntry == NULL) { + return; + } + + operationToPerform(currentListEntry, + additionalDataNeededForCallbackFunction); + currentListEntry = nextListEntry; + + while(currentListEntry != NULL) { + nextListEntry = currentListEntry->prevListEntry; + operationToPerform(currentListEntry, + additionalDataNeededForCallbackFunction); + currentListEntry = nextListEntry; + } +} + +void list_freeList(list_t *list) { + if(list){ + list_iterateThroughListForward(list, listEntry_free, NULL); + free(list); + } +} + +void list_addElement(list_t *list, void *dataToAddInList) { + listEntry_t *newListEntry = listEntry_create(dataToAddInList); + if(newListEntry == NULL) { + // TODO Malloc Failure + return; + } + if(list->firstEntry == NULL) { + list->firstEntry = newListEntry; + list->lastEntry = newListEntry; + + newListEntry->prevListEntry = NULL; + newListEntry->nextListEntry = NULL; + + list->count++; + + return; + } + + list->lastEntry->nextListEntry = newListEntry; + newListEntry->prevListEntry = list->lastEntry; + newListEntry->nextListEntry = NULL; + list->lastEntry = newListEntry; + + list->count++; +} + +void list_removeElement(list_t *list, listEntry_t *elementToRemove) { + listEntry_t *elementBeforeElementToRemove = + elementToRemove->prevListEntry; + listEntry_t *elementAfterElementToRemove = + elementToRemove->nextListEntry; + + if(elementBeforeElementToRemove != NULL) { + elementBeforeElementToRemove->nextListEntry = + elementAfterElementToRemove; + } else { + list->firstEntry = elementAfterElementToRemove; + } + + if(elementAfterElementToRemove != NULL) { + elementAfterElementToRemove->prevListEntry = + elementBeforeElementToRemove; + } else { + list->lastEntry = elementBeforeElementToRemove; + } + + listEntry_free(elementToRemove, NULL); + + list->count--; +} + +listEntry_t *list_getElementAt(list_t *list, long indexOfElement) { + listEntry_t *currentListEntry; + + if((list->count / 2) > indexOfElement) { + currentListEntry = list->firstEntry; + + for(int i = 0; i < indexOfElement; i++) { + currentListEntry = currentListEntry->nextListEntry; + } + + return currentListEntry; + } else { + currentListEntry = list->lastEntry; + + for(int i = 1; i < (list->count - indexOfElement); i++) { + currentListEntry = currentListEntry->prevListEntry; + } + + return currentListEntry; + } +} + +char* findStrInStrList(list_t *strList, const char *str) +{ + if (!strList || !str) { + return NULL; + } + + listEntry_t* listEntry = NULL; + list_ForEach(listEntry, strList) { + if (strstr(listEntry->data, str) != NULL) { + return listEntry->data; + } + } + + return NULL; +} + +void clear_and_free_string_list(list_t *list) +{ + if (!list) { + return; + } + + listEntry_t *listEntry = NULL; + list_ForEach(listEntry, list) { + char *list_item = listEntry->data; + free(list_item); + list_item = NULL; + } + list_freeList(list); +} diff --git a/samples/client/petstore/apex/config/project-scratch-def.json b/samples/client/petstore/apex/config/project-scratch-def.json index e69de29bb2d1..36aace552669 100644 --- a/samples/client/petstore/apex/config/project-scratch-def.json +++ b/samples/client/petstore/apex/config/project-scratch-def.json @@ -0,0 +1,8 @@ +{ + "orgName": "muenzpraeger - René Winkelmeyer", + "edition": "Developer", + "orgPreferences": { + "enabled": ["S1DesktopEnabled"], + "disabled": ["S1EncryptedStoragePref2"] + } +} diff --git a/samples/client/petstore/bash/docs/EnumTest.md b/samples/client/petstore/bash/docs/EnumTest.md index e69de29bb2d1..30b30efa7307 100644 --- a/samples/client/petstore/bash/docs/EnumTest.md +++ b/samples/client/petstore/bash/docs/EnumTest.md @@ -0,0 +1,14 @@ +# Enum_Test + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enumUnderscorestring** | **string** | | [optional] [default to null] +**enumUnderscorestringUnderscorerequired** | **string** | | [default to null] +**enumUnderscoreinteger** | **integer** | | [optional] [default to null] +**enumUnderscorenumber** | **float** | | [optional] [default to null] +**outerEnum** | [**OuterEnum**](OuterEnum.md) | | [optional] [default to null] + +[[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/bash/docs/MapTest.md b/samples/client/petstore/bash/docs/MapTest.md index e4ed4a233829..e69de29bb2d1 100644 --- a/samples/client/petstore/bash/docs/MapTest.md +++ b/samples/client/petstore/bash/docs/MapTest.md @@ -1,13 +0,0 @@ -# MapTest - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**mapUnderscoremapUnderscoreofUnderscorestring** | **map[String, map[String, string]]** | | [optional] [default to null] -**mapUnderscoreofUnderscoreenumUnderscorestring** | **map[String, string]** | | [optional] [default to null] -**directUnderscoremap** | **map[String, boolean]** | | [optional] [default to null] -**indirectUnderscoremap** | **map[String, boolean]** | | [optional] [default to null] - -[[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/c-useJsonUnformatted/model/model_with_set_propertes.h b/samples/client/petstore/c-useJsonUnformatted/model/model_with_set_propertes.h index e69de29bb2d1..aa82893b94bb 100644 --- a/samples/client/petstore/c-useJsonUnformatted/model/model_with_set_propertes.h +++ b/samples/client/petstore/c-useJsonUnformatted/model/model_with_set_propertes.h @@ -0,0 +1,41 @@ +/* + * model_with_set_propertes.h + * + * to test set properties + */ + +#ifndef _model_with_set_propertes_H_ +#define _model_with_set_propertes_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +typedef struct model_with_set_propertes_t model_with_set_propertes_t; + +#include "tag.h" + + + +typedef struct model_with_set_propertes_t { + list_t *tag_set; //nonprimitive container + list_t *string_set; //primitive container + + int _library_owned; // Is the library responsible for freeing this object? +} model_with_set_propertes_t; + +__attribute__((deprecated)) model_with_set_propertes_t *model_with_set_propertes_create( + list_t *tag_set, + list_t *string_set +); + +void model_with_set_propertes_free(model_with_set_propertes_t *model_with_set_propertes); + +model_with_set_propertes_t *model_with_set_propertes_parseFromJSON(cJSON *model_with_set_propertesJSON); + +cJSON *model_with_set_propertes_convertToJSON(model_with_set_propertes_t *model_with_set_propertes); + +#endif /* _model_with_set_propertes_H_ */ + diff --git a/samples/client/petstore/c-useJsonUnformatted/model/order.c b/samples/client/petstore/c-useJsonUnformatted/model/order.c index e69de29bb2d1..d67d1d47c714 100644 --- a/samples/client/petstore/c-useJsonUnformatted/model/order.c +++ b/samples/client/petstore/c-useJsonUnformatted/model/order.c @@ -0,0 +1,233 @@ +#include +#include +#include +#include "order.h" + + +char* order_status_ToString(openapi_petstore_order_STATUS_e status) { + char* statusArray[] = { "NULL", "placed", "approved", "delivered" }; + return statusArray[status]; +} + +openapi_petstore_order_STATUS_e order_status_FromString(char* status){ + int stringToReturn = 0; + char *statusArray[] = { "NULL", "placed", "approved", "delivered" }; + size_t sizeofArray = sizeof(statusArray) / sizeof(statusArray[0]); + while(stringToReturn < sizeofArray) { + if(strcmp(status, statusArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; + } + return 0; +} + +static order_t *order_create_internal( + long id, + long pet_id, + int quantity, + char *ship_date, + openapi_petstore_order_STATUS_e status, + int complete + ) { + order_t *order_local_var = malloc(sizeof(order_t)); + if (!order_local_var) { + return NULL; + } + order_local_var->id = id; + order_local_var->pet_id = pet_id; + order_local_var->quantity = quantity; + order_local_var->ship_date = ship_date; + order_local_var->status = status; + order_local_var->complete = complete; + + order_local_var->_library_owned = 1; + return order_local_var; +} + +__attribute__((deprecated)) order_t *order_create( + long id, + long pet_id, + int quantity, + char *ship_date, + openapi_petstore_order_STATUS_e status, + int complete + ) { + return order_create_internal ( + id, + pet_id, + quantity, + ship_date, + status, + complete + ); +} + +void order_free(order_t *order) { + if(NULL == order){ + return ; + } + if(order->_library_owned != 1){ + fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "order_free"); + return ; + } + listEntry_t *listEntry; + if (order->ship_date) { + free(order->ship_date); + order->ship_date = NULL; + } + free(order); +} + +cJSON *order_convertToJSON(order_t *order) { + cJSON *item = cJSON_CreateObject(); + + // order->id + if(order->id) { + if(cJSON_AddNumberToObject(item, "id", order->id) == NULL) { + goto fail; //Numeric + } + } + + + // order->pet_id + if(order->pet_id) { + if(cJSON_AddNumberToObject(item, "petId", order->pet_id) == NULL) { + goto fail; //Numeric + } + } + + + // order->quantity + if(order->quantity) { + if(cJSON_AddNumberToObject(item, "quantity", order->quantity) == NULL) { + goto fail; //Numeric + } + } + + + // order->ship_date + if(order->ship_date) { + if(cJSON_AddStringToObject(item, "shipDate", order->ship_date) == NULL) { + goto fail; //Date-Time + } + } + + + // order->status + if(order->status != openapi_petstore_order_STATUS_NULL) { + if(cJSON_AddStringToObject(item, "status", order_status_ToString(order->status)) == NULL) + { + goto fail; //Enum + } + } + + + // order->complete + if(order->complete) { + if(cJSON_AddBoolToObject(item, "complete", order->complete) == NULL) { + goto fail; //Bool + } + } + + return item; +fail: + if (item) { + cJSON_Delete(item); + } + return NULL; +} + +order_t *order_parseFromJSON(cJSON *orderJSON){ + + order_t *order_local_var = NULL; + + // order->id + cJSON *id = cJSON_GetObjectItemCaseSensitive(orderJSON, "id"); + if (cJSON_IsNull(id)) { + id = NULL; + } + if (id) { + if(!cJSON_IsNumber(id)) + { + goto end; //Numeric + } + } + + // order->pet_id + cJSON *pet_id = cJSON_GetObjectItemCaseSensitive(orderJSON, "petId"); + if (cJSON_IsNull(pet_id)) { + pet_id = NULL; + } + if (pet_id) { + if(!cJSON_IsNumber(pet_id)) + { + goto end; //Numeric + } + } + + // order->quantity + cJSON *quantity = cJSON_GetObjectItemCaseSensitive(orderJSON, "quantity"); + if (cJSON_IsNull(quantity)) { + quantity = NULL; + } + if (quantity) { + if(!cJSON_IsNumber(quantity)) + { + goto end; //Numeric + } + } + + // order->ship_date + cJSON *ship_date = cJSON_GetObjectItemCaseSensitive(orderJSON, "shipDate"); + if (cJSON_IsNull(ship_date)) { + ship_date = NULL; + } + if (ship_date) { + if(!cJSON_IsString(ship_date) && !cJSON_IsNull(ship_date)) + { + goto end; //DateTime + } + } + + // order->status + cJSON *status = cJSON_GetObjectItemCaseSensitive(orderJSON, "status"); + if (cJSON_IsNull(status)) { + status = NULL; + } + openapi_petstore_order_STATUS_e statusVariable; + if (status) { + if(!cJSON_IsString(status)) + { + goto end; //Enum + } + statusVariable = order_status_FromString(status->valuestring); + } + + // order->complete + cJSON *complete = cJSON_GetObjectItemCaseSensitive(orderJSON, "complete"); + if (cJSON_IsNull(complete)) { + complete = NULL; + } + if (complete) { + if(!cJSON_IsBool(complete)) + { + goto end; //Bool + } + } + + + order_local_var = order_create_internal ( + id ? id->valuedouble : 0, + pet_id ? pet_id->valuedouble : 0, + quantity ? quantity->valuedouble : 0, + ship_date && !cJSON_IsNull(ship_date) ? strdup(ship_date->valuestring) : NULL, + status ? statusVariable : openapi_petstore_order_STATUS_NULL, + complete ? complete->valueint : 0 + ); + + return order_local_var; +end: + return NULL; + +} diff --git a/samples/client/petstore/c-useJsonUnformatted/model/pet.c b/samples/client/petstore/c-useJsonUnformatted/model/pet.c index b561634cb529..e69de29bb2d1 100644 --- a/samples/client/petstore/c-useJsonUnformatted/model/pet.c +++ b/samples/client/petstore/c-useJsonUnformatted/model/pet.c @@ -1,335 +0,0 @@ -#include -#include -#include -#include "pet.h" - - -char* pet_status_ToString(openapi_petstore_pet_STATUS_e status) { - char* statusArray[] = { "NULL", "available", "pending", "sold" }; - return statusArray[status]; -} - -openapi_petstore_pet_STATUS_e pet_status_FromString(char* status){ - int stringToReturn = 0; - char *statusArray[] = { "NULL", "available", "pending", "sold" }; - size_t sizeofArray = sizeof(statusArray) / sizeof(statusArray[0]); - while(stringToReturn < sizeofArray) { - if(strcmp(status, statusArray[stringToReturn]) == 0) { - return stringToReturn; - } - stringToReturn++; - } - return 0; -} - -static pet_t *pet_create_internal( - long id, - category_t *category, - char *name, - list_t *photo_urls, - list_t *tags, - openapi_petstore_pet_STATUS_e status - ) { - pet_t *pet_local_var = malloc(sizeof(pet_t)); - if (!pet_local_var) { - return NULL; - } - pet_local_var->id = id; - pet_local_var->category = category; - pet_local_var->name = name; - pet_local_var->photo_urls = photo_urls; - pet_local_var->tags = tags; - pet_local_var->status = status; - - pet_local_var->_library_owned = 1; - return pet_local_var; -} - -__attribute__((deprecated)) pet_t *pet_create( - long id, - category_t *category, - char *name, - list_t *photo_urls, - list_t *tags, - openapi_petstore_pet_STATUS_e status - ) { - return pet_create_internal ( - id, - category, - name, - photo_urls, - tags, - status - ); -} - -void pet_free(pet_t *pet) { - if(NULL == pet){ - return ; - } - if(pet->_library_owned != 1){ - fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "pet_free"); - return ; - } - listEntry_t *listEntry; - if (pet->category) { - category_free(pet->category); - pet->category = NULL; - } - if (pet->name) { - free(pet->name); - pet->name = NULL; - } - if (pet->photo_urls) { - list_ForEach(listEntry, pet->photo_urls) { - free(listEntry->data); - } - list_freeList(pet->photo_urls); - pet->photo_urls = NULL; - } - if (pet->tags) { - list_ForEach(listEntry, pet->tags) { - tag_free(listEntry->data); - } - list_freeList(pet->tags); - pet->tags = NULL; - } - free(pet); -} - -cJSON *pet_convertToJSON(pet_t *pet) { - cJSON *item = cJSON_CreateObject(); - - // pet->id - if(pet->id) { - if(cJSON_AddNumberToObject(item, "id", pet->id) == NULL) { - goto fail; //Numeric - } - } - - - // pet->category - if(pet->category) { - cJSON *category_local_JSON = category_convertToJSON(pet->category); - if(category_local_JSON == NULL) { - goto fail; //model - } - cJSON_AddItemToObject(item, "category", category_local_JSON); - if(item->child == NULL) { - goto fail; - } - } - - - // pet->name - if (!pet->name) { - goto fail; - } - if(cJSON_AddStringToObject(item, "name", pet->name) == NULL) { - goto fail; //String - } - - - // pet->photo_urls - if (!pet->photo_urls) { - goto fail; - } - cJSON *photo_urls = cJSON_AddArrayToObject(item, "photoUrls"); - if(photo_urls == NULL) { - goto fail; //primitive container - } - - listEntry_t *photo_urlsListEntry; - list_ForEach(photo_urlsListEntry, pet->photo_urls) { - if(cJSON_AddStringToObject(photo_urls, "", photo_urlsListEntry->data) == NULL) - { - goto fail; - } - } - - - // pet->tags - if(pet->tags) { - cJSON *tags = cJSON_AddArrayToObject(item, "tags"); - if(tags == NULL) { - goto fail; //nonprimitive container - } - - listEntry_t *tagsListEntry; - if (pet->tags) { - list_ForEach(tagsListEntry, pet->tags) { - cJSON *itemLocal = tag_convertToJSON(tagsListEntry->data); - if(itemLocal == NULL) { - goto fail; - } - cJSON_AddItemToArray(tags, itemLocal); - } - } - } - - - // pet->status - if(pet->status != openapi_petstore_pet_STATUS_NULL) { - if(cJSON_AddStringToObject(item, "status", pet_status_ToString(pet->status)) == NULL) - { - goto fail; //Enum - } - } - - return item; -fail: - if (item) { - cJSON_Delete(item); - } - return NULL; -} - -pet_t *pet_parseFromJSON(cJSON *petJSON){ - - pet_t *pet_local_var = NULL; - - // define the local variable for pet->category - category_t *category_local_nonprim = NULL; - - // define the local list for pet->photo_urls - list_t *photo_urlsList = NULL; - - // define the local list for pet->tags - list_t *tagsList = NULL; - - // pet->id - cJSON *id = cJSON_GetObjectItemCaseSensitive(petJSON, "id"); - if (cJSON_IsNull(id)) { - id = NULL; - } - if (id) { - if(!cJSON_IsNumber(id)) - { - goto end; //Numeric - } - } - - // pet->category - cJSON *category = cJSON_GetObjectItemCaseSensitive(petJSON, "category"); - if (cJSON_IsNull(category)) { - category = NULL; - } - if (category) { - category_local_nonprim = category_parseFromJSON(category); //nonprimitive - } - - // pet->name - cJSON *name = cJSON_GetObjectItemCaseSensitive(petJSON, "name"); - if (cJSON_IsNull(name)) { - name = NULL; - } - if (!name) { - goto end; - } - - - if(!cJSON_IsString(name)) - { - goto end; //String - } - - // pet->photo_urls - cJSON *photo_urls = cJSON_GetObjectItemCaseSensitive(petJSON, "photoUrls"); - if (cJSON_IsNull(photo_urls)) { - photo_urls = NULL; - } - if (!photo_urls) { - goto end; - } - - - cJSON *photo_urls_local = NULL; - if(!cJSON_IsArray(photo_urls)) { - goto end;//primitive container - } - photo_urlsList = list_createList(); - - cJSON_ArrayForEach(photo_urls_local, photo_urls) - { - if(!cJSON_IsString(photo_urls_local)) - { - goto end; - } - list_addElement(photo_urlsList , strdup(photo_urls_local->valuestring)); - } - - // pet->tags - cJSON *tags = cJSON_GetObjectItemCaseSensitive(petJSON, "tags"); - if (cJSON_IsNull(tags)) { - tags = NULL; - } - if (tags) { - cJSON *tags_local_nonprimitive = NULL; - if(!cJSON_IsArray(tags)){ - goto end; //nonprimitive container - } - - tagsList = list_createList(); - - cJSON_ArrayForEach(tags_local_nonprimitive,tags ) - { - if(!cJSON_IsObject(tags_local_nonprimitive)){ - goto end; - } - tag_t *tagsItem = tag_parseFromJSON(tags_local_nonprimitive); - - list_addElement(tagsList, tagsItem); - } - } - - // pet->status - cJSON *status = cJSON_GetObjectItemCaseSensitive(petJSON, "status"); - if (cJSON_IsNull(status)) { - status = NULL; - } - openapi_petstore_pet_STATUS_e statusVariable; - if (status) { - if(!cJSON_IsString(status)) - { - goto end; //Enum - } - statusVariable = pet_status_FromString(status->valuestring); - } - - - pet_local_var = pet_create_internal ( - id ? id->valuedouble : 0, - category ? category_local_nonprim : NULL, - strdup(name->valuestring), - photo_urlsList, - tags ? tagsList : NULL, - status ? statusVariable : openapi_petstore_pet_STATUS_NULL - ); - - return pet_local_var; -end: - if (category_local_nonprim) { - category_free(category_local_nonprim); - category_local_nonprim = NULL; - } - if (photo_urlsList) { - listEntry_t *listEntry = NULL; - list_ForEach(listEntry, photo_urlsList) { - free(listEntry->data); - listEntry->data = NULL; - } - list_freeList(photo_urlsList); - photo_urlsList = NULL; - } - if (tagsList) { - listEntry_t *listEntry = NULL; - list_ForEach(listEntry, tagsList) { - tag_free(listEntry->data); - listEntry->data = NULL; - } - list_freeList(tagsList); - tagsList = NULL; - } - return NULL; - -} diff --git a/samples/client/petstore/c/model/api_response.c b/samples/client/petstore/c/model/api_response.c index e69de29bb2d1..d0169c84f5b2 100644 --- a/samples/client/petstore/c/model/api_response.c +++ b/samples/client/petstore/c/model/api_response.c @@ -0,0 +1,142 @@ +#include +#include +#include +#include "api_response.h" + + + +static api_response_t *api_response_create_internal( + int code, + char *type, + char *message + ) { + api_response_t *api_response_local_var = malloc(sizeof(api_response_t)); + if (!api_response_local_var) { + return NULL; + } + api_response_local_var->code = code; + api_response_local_var->type = type; + api_response_local_var->message = message; + + api_response_local_var->_library_owned = 1; + return api_response_local_var; +} + +__attribute__((deprecated)) api_response_t *api_response_create( + int code, + char *type, + char *message + ) { + return api_response_create_internal ( + code, + type, + message + ); +} + +void api_response_free(api_response_t *api_response) { + if(NULL == api_response){ + return ; + } + if(api_response->_library_owned != 1){ + fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "api_response_free"); + return ; + } + listEntry_t *listEntry; + if (api_response->type) { + free(api_response->type); + api_response->type = NULL; + } + if (api_response->message) { + free(api_response->message); + api_response->message = NULL; + } + free(api_response); +} + +cJSON *api_response_convertToJSON(api_response_t *api_response) { + cJSON *item = cJSON_CreateObject(); + + // api_response->code + if(api_response->code) { + if(cJSON_AddNumberToObject(item, "code", api_response->code) == NULL) { + goto fail; //Numeric + } + } + + + // api_response->type + if(api_response->type) { + if(cJSON_AddStringToObject(item, "type", api_response->type) == NULL) { + goto fail; //String + } + } + + + // api_response->message + if(api_response->message) { + if(cJSON_AddStringToObject(item, "message", api_response->message) == NULL) { + goto fail; //String + } + } + + return item; +fail: + if (item) { + cJSON_Delete(item); + } + return NULL; +} + +api_response_t *api_response_parseFromJSON(cJSON *api_responseJSON){ + + api_response_t *api_response_local_var = NULL; + + // api_response->code + cJSON *code = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "code"); + if (cJSON_IsNull(code)) { + code = NULL; + } + if (code) { + if(!cJSON_IsNumber(code)) + { + goto end; //Numeric + } + } + + // api_response->type + cJSON *type = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "type"); + if (cJSON_IsNull(type)) { + type = NULL; + } + if (type) { + if(!cJSON_IsString(type) && !cJSON_IsNull(type)) + { + goto end; //String + } + } + + // api_response->message + cJSON *message = cJSON_GetObjectItemCaseSensitive(api_responseJSON, "message"); + if (cJSON_IsNull(message)) { + message = NULL; + } + if (message) { + if(!cJSON_IsString(message) && !cJSON_IsNull(message)) + { + goto end; //String + } + } + + + api_response_local_var = api_response_create_internal ( + code ? code->valuedouble : 0, + type && !cJSON_IsNull(type) ? strdup(type->valuestring) : NULL, + message && !cJSON_IsNull(message) ? strdup(message->valuestring) : NULL + ); + + return api_response_local_var; +end: + return NULL; + +} diff --git a/samples/client/petstore/c/model/category.c b/samples/client/petstore/c/model/category.c index 2b060a568015..e69de29bb2d1 100644 --- a/samples/client/petstore/c/model/category.c +++ b/samples/client/petstore/c/model/category.c @@ -1,113 +0,0 @@ -#include -#include -#include -#include "category.h" - - - -static category_t *category_create_internal( - long id, - char *name - ) { - category_t *category_local_var = malloc(sizeof(category_t)); - if (!category_local_var) { - return NULL; - } - category_local_var->id = id; - category_local_var->name = name; - - category_local_var->_library_owned = 1; - return category_local_var; -} - -__attribute__((deprecated)) category_t *category_create( - long id, - char *name - ) { - return category_create_internal ( - id, - name - ); -} - -void category_free(category_t *category) { - if(NULL == category){ - return ; - } - if(category->_library_owned != 1){ - fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "category_free"); - return ; - } - listEntry_t *listEntry; - if (category->name) { - free(category->name); - category->name = NULL; - } - free(category); -} - -cJSON *category_convertToJSON(category_t *category) { - cJSON *item = cJSON_CreateObject(); - - // category->id - if(category->id) { - if(cJSON_AddNumberToObject(item, "id", category->id) == NULL) { - goto fail; //Numeric - } - } - - - // category->name - if(category->name) { - if(cJSON_AddStringToObject(item, "name", category->name) == NULL) { - goto fail; //String - } - } - - return item; -fail: - if (item) { - cJSON_Delete(item); - } - return NULL; -} - -category_t *category_parseFromJSON(cJSON *categoryJSON){ - - category_t *category_local_var = NULL; - - // category->id - cJSON *id = cJSON_GetObjectItemCaseSensitive(categoryJSON, "id"); - if (cJSON_IsNull(id)) { - id = NULL; - } - if (id) { - if(!cJSON_IsNumber(id)) - { - goto end; //Numeric - } - } - - // category->name - cJSON *name = cJSON_GetObjectItemCaseSensitive(categoryJSON, "name"); - if (cJSON_IsNull(name)) { - name = NULL; - } - if (name) { - if(!cJSON_IsString(name) && !cJSON_IsNull(name)) - { - goto end; //String - } - } - - - category_local_var = category_create_internal ( - id ? id->valuedouble : 0, - name && !cJSON_IsNull(name) ? strdup(name->valuestring) : NULL - ); - - return category_local_var; -end: - return NULL; - -} diff --git a/samples/client/petstore/c/model/category.h b/samples/client/petstore/c/model/category.h index e69de29bb2d1..bd27e27e35a3 100644 --- a/samples/client/petstore/c/model/category.h +++ b/samples/client/petstore/c/model/category.h @@ -0,0 +1,40 @@ +/* + * category.h + * + * A category for a pet + */ + +#ifndef _category_H_ +#define _category_H_ + +#include +#include "../external/cJSON.h" +#include "../include/list.h" +#include "../include/keyValuePair.h" +#include "../include/binary.h" + +typedef struct category_t category_t; + + + + +typedef struct category_t { + long id; //numeric + char *name; // string + + int _library_owned; // Is the library responsible for freeing this object? +} category_t; + +__attribute__((deprecated)) category_t *category_create( + long id, + char *name +); + +void category_free(category_t *category); + +category_t *category_parseFromJSON(cJSON *categoryJSON); + +cJSON *category_convertToJSON(category_t *category); + +#endif /* _category_H_ */ + diff --git a/samples/client/petstore/cpp-oatpp/api/StoreApi.hpp b/samples/client/petstore/cpp-oatpp/api/StoreApi.hpp index f48ec25ab0ab..e69de29bb2d1 100644 --- a/samples/client/petstore/cpp-oatpp/api/StoreApi.hpp +++ b/samples/client/petstore/cpp-oatpp/api/StoreApi.hpp @@ -1,77 +0,0 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* 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. -*/ -/* - * StoreApi.h - * - * - */ - -#ifndef StoreApi_H_ -#define StoreApi_H_ - - - -#include "oatpp/web/client/ApiClient.hpp" -#include "oatpp/web/protocol/http/outgoing/MultipartBody.hpp" -#include "oatpp/core/macro/codegen.hpp" - -#include "Order.hpp" - -#include OATPP_CODEGEN_BEGIN(ApiClient) ///< Begin code-gen section - -namespace org::openapitools::client::api -{ - -class StoreApi : public oatpp::web::client::ApiClient { -public: - - API_CLIENT_INIT(StoreApi) - - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// - /// ID of the order that needs to be deleted - API_CALL("DELETE", "/store/order/{orderId}", delete_order, PATH(oatpp::String, orderId)) - /// - /// Returns pet inventories by status - /// - /// - /// Returns a map of status codes to quantities - /// - API_CALL("GET", "/store/inventory", get_inventory) - /// - /// Find purchase order by ID - /// - /// - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions - /// - /// ID of pet that needs to be fetched - API_CALL("GET", "/store/order/{orderId}", get_order_by_id, PATH(oatpp::Int64, orderId)) - /// - /// Place an order for a pet - /// - /// - /// - /// - /// order placed for purchasing the pet - API_CALL("POST", "/store/order", place_order, BODY_DTO(oatpp::Object, order)) -}; - -#include OATPP_CODEGEN_END(ApiClient) ///< End code-gen section - -} // namespace org::openapitools::client::api - -#endif /* StoreApi_H_ */ - diff --git a/samples/client/petstore/cpp-oatpp/model/Tag.hpp b/samples/client/petstore/cpp-oatpp/model/Tag.hpp index e69de29bb2d1..befd6854d51e 100644 --- a/samples/client/petstore/cpp-oatpp/model/Tag.hpp +++ b/samples/client/petstore/cpp-oatpp/model/Tag.hpp @@ -0,0 +1,51 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* 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. +*/ +/* + * Tag.h + * + * A tag for a pet + */ + +#ifndef Tag_H_ +#define Tag_H_ + + +#include "oatpp/core/macro/codegen.hpp" +#include "oatpp/core/Types.hpp" + +namespace org::openapitools::client::model +{ + +/* Begin DTO code-generation */ +#include OATPP_CODEGEN_BEGIN(DTO) + +/** + * Message Data-Transfer-Object + */ +class Tag : public oatpp::DTO { + + DTO_INIT(Tag, DTO /* Extends */) + + DTO_FIELD(oatpp::Int64, id); + DTO_FIELD(oatpp::Boolean, idIsSet); + DTO_FIELD(oatpp::String, name); + DTO_FIELD(oatpp::Boolean, nameIsSet); + +}; + +/* End DTO code-generation */ +#include OATPP_CODEGEN_END(DTO) + + +} // namespace org::openapitools::client::model + +#endif /* Tag_H_ */ diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp index 8fbef0fb8c5c..e69de29bb2d1 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp @@ -1,160 +0,0 @@ -/** - * OpenAPI Petstore - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * 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. - */ - -#include "PFXApiResponse.h" - -#include -#include -#include -#include - -#include "PFXHelpers.h" - -namespace test_namespace { - -PFXApiResponse::PFXApiResponse(QString json) { - this->initializeModel(); - this->fromJson(json); -} - -PFXApiResponse::PFXApiResponse() { - this->initializeModel(); -} - -PFXApiResponse::~PFXApiResponse() {} - -void PFXApiResponse::initializeModel() { - - m_code_isSet = false; - m_code_isValid = false; - - m_type_isSet = false; - m_type_isValid = false; - - m_message_isSet = false; - m_message_isValid = false; -} - -void PFXApiResponse::fromJson(QString jsonString) { - QByteArray array(jsonString.toStdString().c_str()); - QJsonDocument doc = QJsonDocument::fromJson(array); - QJsonObject jsonObject = doc.object(); - this->fromJsonObject(jsonObject); -} - -void PFXApiResponse::fromJsonObject(QJsonObject json) { - - m_code_isValid = ::test_namespace::fromJsonValue(m_code, json[QString("code")]); - m_code_isSet = !json[QString("code")].isNull() && m_code_isValid; - - m_type_isValid = ::test_namespace::fromJsonValue(m_type, json[QString("type")]); - m_type_isSet = !json[QString("type")].isNull() && m_type_isValid; - - m_message_isValid = ::test_namespace::fromJsonValue(m_message, json[QString("message")]); - m_message_isSet = !json[QString("message")].isNull() && m_message_isValid; -} - -QString PFXApiResponse::asJson() const { - QJsonObject obj = this->asJsonObject(); - QJsonDocument doc(obj); - QByteArray bytes = doc.toJson(); - return QString(bytes); -} - -QJsonObject PFXApiResponse::asJsonObject() const { - QJsonObject obj; - if (m_code_isSet) { - obj.insert(QString("code"), ::test_namespace::toJsonValue(m_code)); - } - if (m_type_isSet) { - obj.insert(QString("type"), ::test_namespace::toJsonValue(m_type)); - } - if (m_message_isSet) { - obj.insert(QString("message"), ::test_namespace::toJsonValue(m_message)); - } - return obj; -} - -qint32 PFXApiResponse::getCode() const { - return m_code; -} -void PFXApiResponse::setCode(const qint32 &code) { - m_code = code; - m_code_isSet = true; -} - -bool PFXApiResponse::is_code_Set() const{ - return m_code_isSet; -} - -bool PFXApiResponse::is_code_Valid() const{ - return m_code_isValid; -} - -QString PFXApiResponse::getType() const { - return m_type; -} -void PFXApiResponse::setType(const QString &type) { - m_type = type; - m_type_isSet = true; -} - -bool PFXApiResponse::is_type_Set() const{ - return m_type_isSet; -} - -bool PFXApiResponse::is_type_Valid() const{ - return m_type_isValid; -} - -QString PFXApiResponse::getMessage() const { - return m_message; -} -void PFXApiResponse::setMessage(const QString &message) { - m_message = message; - m_message_isSet = true; -} - -bool PFXApiResponse::is_message_Set() const{ - return m_message_isSet; -} - -bool PFXApiResponse::is_message_Valid() const{ - return m_message_isValid; -} - -bool PFXApiResponse::isSet() const { - bool isObjectUpdated = false; - do { - if (m_code_isSet) { - isObjectUpdated = true; - break; - } - - if (m_type_isSet) { - isObjectUpdated = true; - break; - } - - if (m_message_isSet) { - isObjectUpdated = true; - break; - } - } while (false); - return isObjectUpdated; -} - -bool PFXApiResponse::isValid() const { - // only required properties are required for the object to be considered valid - return true; -} - -} // namespace test_namespace diff --git a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/appsettings.json index e69de29bb2d1..def9159a7d94 100644 --- a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/appsettings.json index e69de29bb2d1..def9159a7d94 100644 --- a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs index 97ae99c9295a..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs +++ b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs @@ -1,60 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.Linq; -using System.Text.RegularExpressions; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// BasePath Document Filter sets BasePath property of OpenAPI and removes it from the individual URL paths - /// - public class BasePathFilter : IDocumentFilter - { - /// - /// Constructor - /// - /// BasePath to remove from Operations - public BasePathFilter(string basePath) - { - BasePath = basePath; - } - - /// - /// Gets the BasePath of the OpenAPI Doc - /// - /// The BasePath of the OpenAPI Doc - public string BasePath { get; } - - /// - /// Apply the filter - /// - /// OpenApiDocument - /// FilterContext - public void Apply(OpenApiDocument openapiDoc, DocumentFilterContext context) - { - //openapiDoc.BasePath = BasePath; - - var pathsToModify = openapiDoc.Paths.Where(p => p.Key.StartsWith(BasePath)).ToList(); - - foreach (var (key, value) in pathsToModify) - { - if (key.StartsWith(BasePath)) - { - var newKey = Regex.Replace(key, $"^{BasePath}", string.Empty); - openapiDoc.Paths.Remove(key); - openapiDoc.Paths.Add(newKey, value); - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/appsettings.json index e69de29bb2d1..def9159a7d94 100644 --- a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json index e69de29bb2d1..def9159a7d94 100644 --- a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile index e69de29bb2d1..7184e1ece4d0 100644 --- a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile +++ b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# Container we use for final publish +FROM mcr.microsoft.com/dotnet/core/aspnet:6.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Build container +FROM mcr.microsoft.com/dotnet/core/sdk:6.0-buster AS build + +# Copy the code into the container +WORKDIR /src +COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] + +# NuGet restore +RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" +COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] + +# Build the API +WORKDIR "Org.OpenAPITools" +RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build + +# Publish it +FROM build AS publish +RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish + +# Make the final image for publishing +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/appsettings.json index e69de29bb2d1..def9159a7d94 100644 --- a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs index e69de29bb2d1..122f58cabe4a 100644 --- a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs +++ b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/OpenApi/TypeExtensions.cs @@ -0,0 +1,61 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.Linq; +using System.Text; + +namespace Org.OpenAPITools.OpenApi +{ + /// + /// Replacement utilities from Swashbuckle.AspNetCore.SwaggerGen which are not in 5.x + /// + public static class TypeExtensions + { + /// + /// Produce a friendly name for the type which is unique. + /// + /// + /// + public static string FriendlyId(this Type type, bool fullyQualified = false) + { + var typeName = fullyQualified + ? type.FullNameSansTypeParameters().Replace("+", ".") + : type.Name; + + if (type.IsGenericType) + { + var genericArgumentIds = type.GetGenericArguments() + .Select(t => t.FriendlyId(fullyQualified)) + .ToArray(); + + return new StringBuilder(typeName) + .Replace($"`{genericArgumentIds.Count()}", string.Empty) + .Append($"[{string.Join(",", genericArgumentIds).TrimEnd(',')}]") + .ToString(); + } + + return typeName; + } + + /// + /// Determine the fully qualified type name without type parameters. + /// + /// + public static string FullNameSansTypeParameters(this Type type) + { + var fullName = type.FullName; + if (string.IsNullOrEmpty(fullName)) + fullName = type.Name; + var chopIndex = fullName.IndexOf("[[", StringComparison.Ordinal); + return (chopIndex == -1) ? fullName : fullName.Substring(0, chopIndex); + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json index b47dce3d2c68..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json +++ b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -1,1203 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", - "license" : { - "name" : "Apache-2.0", - "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" - }, - "title" : "OpenAPI Petstore", - "version" : "1.0.0" - }, - "externalDocs" : { - "description" : "Find out more about Swagger", - "url" : "http://swagger.io" - }, - "servers" : [ { - "url" : "http://petstore.swagger.io/v2" - } ], - "tags" : [ { - "description" : "Everything about your Pets", - "name" : "pet" - }, { - "description" : "Access to Petstore orders", - "name" : "store" - }, { - "description" : "Operations about user", - "name" : "user" - } ], - "paths" : { - "/test" : { - "get" : { - "parameters" : [ { - "explode" : true, - "in" : "query", - "name" : "testQuery", - "required" : false, - "schema" : { - "$ref" : "#/components/schemas/TestEnum" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "description" : "OK" - } - }, - "summary" : "Test API" - } - }, - "/pet" : { - "post" : { - "description" : "", - "operationId" : "addPet", - "requestBody" : { - "$ref" : "#/components/requestBodies/Pet" - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Add a new pet to the store", - "tags" : [ "pet" ] - }, - "put" : { - "description" : "", - "operationId" : "updatePet", - "requestBody" : { - "$ref" : "#/components/requestBodies/Pet" - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Pet not found" - }, - "405" : { - "description" : "Validation exception" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Update an existing pet", - "tags" : [ "pet" ] - } - }, - "/pet/findByStatus" : { - "get" : { - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findPetsByStatus", - "parameters" : [ { - "deprecated" : true, - "description" : "Status values that need to be considered for filter", - "explode" : false, - "in" : "query", - "name" : "status", - "required" : true, - "schema" : { - "items" : { - "default" : "available", - "enum" : [ "available", "pending", "sold" ], - "type" : "string" - }, - "type" : "array" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - }, - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid status value" - } - }, - "security" : [ { - "petstore_auth" : [ "read:pets" ] - } ], - "summary" : "Finds Pets by status", - "tags" : [ "pet" ] - } - }, - "/pet/findByTags" : { - "get" : { - "deprecated" : true, - "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "parameters" : [ { - "description" : "Tags to filter by", - "explode" : false, - "in" : "query", - "name" : "tags", - "required" : true, - "schema" : { - "items" : { - "type" : "string" - }, - "type" : "array" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - }, - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid tag value" - } - }, - "security" : [ { - "petstore_auth" : [ "read:pets" ] - } ], - "summary" : "Finds Pets by tags", - "tags" : [ "pet" ] - } - }, - "/pet/{petId}" : { - "delete" : { - "description" : "", - "operationId" : "deletePet", - "parameters" : [ { - "explode" : false, - "in" : "header", - "name" : "api_key", - "required" : false, - "schema" : { - "type" : "string" - }, - "style" : "simple" - }, { - "description" : "Pet id to delete", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "responses" : { - "400" : { - "description" : "Invalid pet value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Deletes a pet", - "tags" : [ "pet" ] - }, - "get" : { - "description" : "Returns a single pet", - "operationId" : "getPetById", - "parameters" : [ { - "description" : "ID of pet to return", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Pet not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Find pet by ID", - "tags" : [ "pet" ] - }, - "post" : { - "description" : "", - "operationId" : "updatePetWithForm", - "parameters" : [ { - "description" : "ID of pet that needs to be updated", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "$ref" : "#/components/schemas/updatePetWithForm_request" - } - } - } - }, - "responses" : { - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Updates a pet in the store with form data", - "tags" : [ "pet" ] - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "description" : "", - "operationId" : "uploadFile", - "parameters" : [ { - "description" : "ID of pet to update", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "requestBody" : { - "content" : { - "multipart/form-data" : { - "schema" : { - "$ref" : "#/components/schemas/uploadFile_request" - } - } - } - }, - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ApiResponse" - } - } - }, - "description" : "successful operation" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "uploads an image", - "tags" : [ "pet" ] - } - }, - "/store/inventory" : { - "get" : { - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "additionalProperties" : { - "format" : "int32", - "type" : "integer" - }, - "type" : "object" - } - } - }, - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Returns pet inventories by status", - "tags" : [ "store" ] - } - }, - "/store/order" : { - "post" : { - "description" : "", - "operationId" : "placeOrder", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "order placed for purchasing the pet", - "required" : true - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid Order" - } - }, - "summary" : "Place an order for a pet", - "tags" : [ "store" ] - } - }, - "/store/order/{orderId}" : { - "delete" : { - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "description" : "ID of the order that needs to be deleted", - "explode" : false, - "in" : "path", - "name" : "orderId", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Order not found" - } - }, - "summary" : "Delete purchase order by ID", - "tags" : [ "store" ] - }, - "get" : { - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", - "operationId" : "getOrderById", - "parameters" : [ { - "description" : "ID of pet that needs to be fetched", - "explode" : false, - "in" : "path", - "name" : "orderId", - "required" : true, - "schema" : { - "format" : "int64", - "maximum" : 5, - "minimum" : 1, - "type" : "integer" - }, - "style" : "simple" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Order not found" - } - }, - "summary" : "Find purchase order by ID", - "tags" : [ "store" ] - } - }, - "/user" : { - "post" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Created user object", - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Create user", - "tags" : [ "user" ] - } - }, - "/user/createWithArray" : { - "post" : { - "description" : "", - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Creates list of users with given input array", - "tags" : [ "user" ] - } - }, - "/user/createWithList" : { - "post" : { - "description" : "", - "operationId" : "createUsersWithListInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Creates list of users with given input array", - "tags" : [ "user" ] - } - }, - "/user/login" : { - "get" : { - "description" : "", - "operationId" : "loginUser", - "parameters" : [ { - "description" : "The user name for login", - "explode" : true, - "in" : "query", - "name" : "username", - "required" : true, - "schema" : { - "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", - "type" : "string" - }, - "style" : "form" - }, { - "description" : "The password for login in clear text", - "explode" : true, - "in" : "query", - "name" : "password", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - }, - "description" : "successful operation", - "headers" : { - "Set-Cookie" : { - "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", - "explode" : false, - "schema" : { - "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", - "type" : "string" - }, - "style" : "simple" - }, - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "explode" : false, - "schema" : { - "format" : "int32", - "type" : "integer" - }, - "style" : "simple" - }, - "X-Expires-After" : { - "description" : "date in UTC when token expires", - "explode" : false, - "schema" : { - "format" : "date-time", - "type" : "string" - }, - "style" : "simple" - } - } - }, - "400" : { - "description" : "Invalid username/password supplied" - } - }, - "summary" : "Logs user into the system", - "tags" : [ "user" ] - } - }, - "/user/logout" : { - "get" : { - "description" : "", - "operationId" : "logoutUser", - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Logs out current logged in user session", - "tags" : [ "user" ] - } - }, - "/user/{username}" : { - "delete" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "description" : "The name that needs to be deleted", - "explode" : false, - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Delete user", - "tags" : [ "user" ] - }, - "get" : { - "description" : "", - "operationId" : "getUserByName", - "parameters" : [ { - "description" : "The name that needs to be fetched. Use user1 for testing.", - "explode" : false, - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - }, - "summary" : "Get user by user name", - "tags" : [ "user" ] - }, - "put" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "description" : "name that need to be deleted", - "explode" : false, - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Updated user object", - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid user supplied" - }, - "404" : { - "description" : "User not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Updated user", - "tags" : [ "user" ] - } - }, - "/fake/parameter_example_test" : { - "get" : { - "description" : "", - "operationId" : "fake_parameter_example_test", - "parameters" : [ { - "explode" : true, - "in" : "query", - "name" : "data", - "required" : true, - "schema" : { - "$ref" : "#/components/schemas/Pet" - }, - "style" : "form" - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "summary" : "fake endpoint to test parameter example (object)", - "tags" : [ "fake" ] - } - }, - "/fake/nullable_example_test" : { - "get" : { - "description" : "", - "operationId" : "fake_nullable_example_test", - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/TestNullable" - } - } - }, - "description" : "Successful operation" - } - }, - "summary" : "Fake endpoint to test nullable example (object)", - "tags" : [ "fake" ] - } - } - }, - "components" : { - "requestBodies" : { - "UserArray" : { - "content" : { - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/User" - }, - "type" : "array" - } - } - }, - "description" : "List of user object", - "required" : true - }, - "Pet" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "Pet object that needs to be added to the store", - "required" : true - } - }, - "schemas" : { - "TestEnum" : { - "enum" : [ "A", "B" ], - "type" : "string" - }, - "TestNullable" : { - "example" : { - "nullableName" : "nullableName", - "name" : "name" - }, - "properties" : { - "name" : { - "type" : "string" - }, - "nullableName" : { - "nullable" : true, - "type" : "string" - } - }, - "type" : "object" - }, - "Order" : { - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "petId" : { - "format" : "int64", - "type" : "integer" - }, - "quantity" : { - "format" : "int32", - "type" : "integer" - }, - "shipDate" : { - "format" : "date-time", - "type" : "string" - }, - "status" : { - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ], - "type" : "string" - }, - "complete" : { - "default" : false, - "type" : "boolean" - } - }, - "title" : "Pet Order", - "type" : "object", - "xml" : { - "name" : "Order" - } - }, - "Category" : { - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "name" : { - "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", - "type" : "string" - } - }, - "title" : "Pet category", - "type" : "object", - "xml" : { - "name" : "Category" - } - }, - "User" : { - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "description" : "User Status", - "format" : "int32", - "type" : "integer" - } - }, - "title" : "a User", - "type" : "object", - "xml" : { - "name" : "User" - } - }, - "Tag" : { - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "name" : { - "type" : "string" - } - }, - "title" : "Pet Tag", - "type" : "object", - "xml" : { - "name" : "Tag" - } - }, - "Pet" : { - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "example" : "doggie", - "type" : "string" - }, - "photoUrls" : { - "items" : { - "type" : "string" - }, - "type" : "array", - "xml" : { - "name" : "photoUrl", - "wrapped" : true - } - }, - "tags" : { - "items" : { - "$ref" : "#/components/schemas/Tag" - }, - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - } - }, - "status" : { - "deprecated" : true, - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ], - "type" : "string" - } - }, - "required" : [ "name", "photoUrls" ], - "title" : "a Pet", - "type" : "object", - "xml" : { - "name" : "Pet" - } - }, - "ApiResponse" : { - "description" : "Describes the result of uploading an image resource", - "example" : { - "code" : 0, - "type" : "type", - "message" : "message" - }, - "properties" : { - "code" : { - "format" : "int32", - "type" : "integer" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - }, - "title" : "An uploaded response", - "type" : "object" - }, - "Dog" : { - "allOf" : [ { - "$ref" : "#/components/schemas/Animal" - }, { - "properties" : { - "breed" : { - "type" : "string" - } - }, - "type" : "object" - } ] - }, - "Cat" : { - "allOf" : [ { - "$ref" : "#/components/schemas/Animal" - }, { - "properties" : { - "declawed" : { - "type" : "boolean" - } - }, - "type" : "object" - } ] - }, - "Animal" : { - "discriminator" : { - "mapping" : { - "DOG" : "#/components/schemas/Dog", - "CAT" : "#/components/schemas/Cat" - }, - "propertyName" : "className" - }, - "properties" : { - "className" : { - "type" : "string" - }, - "color" : { - "default" : "red", - "type" : "string" - } - }, - "required" : [ "className" ], - "type" : "object" - }, - "updatePetWithForm_request" : { - "properties" : { - "name" : { - "description" : "Updated name of the pet", - "type" : "string" - }, - "status" : { - "description" : "Updated status of the pet", - "type" : "string" - } - }, - "type" : "object" - }, - "uploadFile_request" : { - "properties" : { - "additionalMetadata" : { - "description" : "Additional data to pass to server", - "type" : "string" - }, - "file" : { - "description" : "file to upload", - "format" : "binary", - "type" : "string" - } - }, - "type" : "object" - } - }, - "securitySchemes" : { - "petstore_auth" : { - "flows" : { - "implicit" : { - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - }, - "type" : "oauth2" - }, - "api_key" : { - "in" : "header", - "name" : "api_key", - "type" : "apiKey" - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs index e69de29bb2d1..18796da30fcb 100644 --- a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +++ b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Formatters; + +namespace Org.OpenAPITools.Formatters +{ + /// + public class InputFormatterStream : InputFormatter + { + /// + public InputFormatterStream() + { + SupportedMediaTypes.Add("application/octet-stream"); + SupportedMediaTypes.Add("image/jpeg"); + } + + /// + public override Task ReadRequestBodyAsync(InputFormatterContext context) + { + return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); + } + + /// + protected override bool CanReadType(Type type) + { + if (type == typeof(Stream)) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec index e69de29bb2d1..b1d83a359618 100644 --- a/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec +++ b/samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec @@ -0,0 +1,20 @@ + + + + $id$ + 1.0.0 + OpenAPI Library + OpenAPI + OpenAPI + https://www.apache.org/licenses/LICENSE-2.0.html + + false + A library generated from a OpenAPI doc + Summary of changes made in this release of the package. + No Copyright + Org.OpenAPITools + + diff --git a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/appsettings.json index e69de29bb2d1..def9159a7d94 100644 --- a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile index e69de29bb2d1..c24f45dbc5a4 100644 --- a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# Container we use for final publish +FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Build container +FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build + +# Copy the code into the container +WORKDIR /src +COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] + +# NuGet restore +RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" +COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] + +# Build the API +WORKDIR "Org.OpenAPITools" +RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build + +# Publish it +FROM build AS publish +RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish + +# Make the final image for publishing +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs index e69de29bb2d1..bf30e991889e 100644 --- a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Startup.cs @@ -0,0 +1,150 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; +using System.Text.Json; +using System.Text.Json.Serialization; +using Org.OpenAPITools.Authentication; +using Org.OpenAPITools.Filters; +using Org.OpenAPITools.OpenApi; +using Org.OpenAPITools.Formatters; + +namespace Org.OpenAPITools +{ + /// + /// Startup + /// + public class Startup + { + /// + /// Constructor + /// + /// + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + /// + /// The application configuration. + /// + public IConfiguration Configuration { get; } + + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddTransient(); + services.AddAuthorization(authConfig => + { + authConfig.AddPolicy("api_key", policyBuilder => + { + policyBuilder + .AddRequirements(new ApiKeyRequirement(new[] { "my-secret-key" },"api_key")); + }); + }); + + // Add framework services. + services + // Don't need the full MVC stack for an API, see https://andrewlock.net/comparing-startup-between-the-asp-net-core-3-templates/ + .AddControllers(options => { + options.InputFormatters.Insert(0, new InputFormatterStream()); + }) + .AddJsonOptions(options => + { + options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)); + }); + services + .AddSwaggerGen(c => + { + c.EnableAnnotations(enableAnnotationsForInheritance: true, enableAnnotationsForPolymorphism: true); + + c.SwaggerDoc("1.0.0", new OpenApiInfo + { + Title = "OpenAPI Petstore", + Description = "OpenAPI Petstore (ASP.NET Core 8.0)", + TermsOfService = new Uri("https://github.com/openapitools/openapi-generator"), + Contact = new OpenApiContact + { + Name = "OpenAPI-Generator Contributors", + Url = new Uri("https://github.com/openapitools/openapi-generator"), + Email = "" + }, + License = new OpenApiLicense + { + Name = "NoLicense", + Url = new Uri("https://www.apache.org/licenses/LICENSE-2.0.html") + }, + Version = "1.0.0", + }); + c.CustomSchemaIds(type => type.FriendlyId(true)); + c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{Assembly.GetExecutingAssembly().GetName().Name}.xml"); + // Sets the basePath property in the OpenAPI document generated + c.DocumentFilter("/v2"); + + // Include DataAnnotation attributes on Controller Action parameters as OpenAPI validation rules (e.g required, pattern, ..) + // Use [ValidateModelState] on Actions to actually validate it in C# as well! + c.OperationFilter(); + }); + } + + /// + /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseDefaultFiles(); + app.UseStaticFiles(); + app.UseSwagger(c => + { + c.RouteTemplate = "openapi/{documentName}/openapi.json"; + }) + .UseSwaggerUI(c => + { + // set route prefix to openapi, e.g. http://localhost:8080/openapi/index.html + c.RoutePrefix = "openapi"; + //TODO: Either use the SwaggerGen generated OpenAPI contract (generated from C# classes) + c.SwaggerEndpoint("/openapi/1.0.0/openapi.json", "OpenAPI Petstore"); + + //TODO: Or alternatively use the original OpenAPI contract that's included in the static files + // c.SwaggerEndpoint("/openapi-original.json", "OpenAPI Petstore Original"); + }); + app.UseRouting(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile index e69de29bb2d1..c24f45dbc5a4 100644 --- a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# Container we use for final publish +FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Build container +FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build + +# Copy the code into the container +WORKDIR /src +COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] + +# NuGet restore +RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" +COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] + +# Build the API +WORKDIR "Org.OpenAPITools" +RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build + +# Publish it +FROM build AS publish +RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish + +# Make the final image for publishing +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json index e69de29bb2d1..def9159a7d94 100644 --- a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json index b47dce3d2c68..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -1,1203 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", - "license" : { - "name" : "Apache-2.0", - "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" - }, - "title" : "OpenAPI Petstore", - "version" : "1.0.0" - }, - "externalDocs" : { - "description" : "Find out more about Swagger", - "url" : "http://swagger.io" - }, - "servers" : [ { - "url" : "http://petstore.swagger.io/v2" - } ], - "tags" : [ { - "description" : "Everything about your Pets", - "name" : "pet" - }, { - "description" : "Access to Petstore orders", - "name" : "store" - }, { - "description" : "Operations about user", - "name" : "user" - } ], - "paths" : { - "/test" : { - "get" : { - "parameters" : [ { - "explode" : true, - "in" : "query", - "name" : "testQuery", - "required" : false, - "schema" : { - "$ref" : "#/components/schemas/TestEnum" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "description" : "OK" - } - }, - "summary" : "Test API" - } - }, - "/pet" : { - "post" : { - "description" : "", - "operationId" : "addPet", - "requestBody" : { - "$ref" : "#/components/requestBodies/Pet" - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Add a new pet to the store", - "tags" : [ "pet" ] - }, - "put" : { - "description" : "", - "operationId" : "updatePet", - "requestBody" : { - "$ref" : "#/components/requestBodies/Pet" - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Pet not found" - }, - "405" : { - "description" : "Validation exception" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Update an existing pet", - "tags" : [ "pet" ] - } - }, - "/pet/findByStatus" : { - "get" : { - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findPetsByStatus", - "parameters" : [ { - "deprecated" : true, - "description" : "Status values that need to be considered for filter", - "explode" : false, - "in" : "query", - "name" : "status", - "required" : true, - "schema" : { - "items" : { - "default" : "available", - "enum" : [ "available", "pending", "sold" ], - "type" : "string" - }, - "type" : "array" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - }, - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid status value" - } - }, - "security" : [ { - "petstore_auth" : [ "read:pets" ] - } ], - "summary" : "Finds Pets by status", - "tags" : [ "pet" ] - } - }, - "/pet/findByTags" : { - "get" : { - "deprecated" : true, - "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "parameters" : [ { - "description" : "Tags to filter by", - "explode" : false, - "in" : "query", - "name" : "tags", - "required" : true, - "schema" : { - "items" : { - "type" : "string" - }, - "type" : "array" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - }, - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid tag value" - } - }, - "security" : [ { - "petstore_auth" : [ "read:pets" ] - } ], - "summary" : "Finds Pets by tags", - "tags" : [ "pet" ] - } - }, - "/pet/{petId}" : { - "delete" : { - "description" : "", - "operationId" : "deletePet", - "parameters" : [ { - "explode" : false, - "in" : "header", - "name" : "api_key", - "required" : false, - "schema" : { - "type" : "string" - }, - "style" : "simple" - }, { - "description" : "Pet id to delete", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "responses" : { - "400" : { - "description" : "Invalid pet value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Deletes a pet", - "tags" : [ "pet" ] - }, - "get" : { - "description" : "Returns a single pet", - "operationId" : "getPetById", - "parameters" : [ { - "description" : "ID of pet to return", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Pet not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Find pet by ID", - "tags" : [ "pet" ] - }, - "post" : { - "description" : "", - "operationId" : "updatePetWithForm", - "parameters" : [ { - "description" : "ID of pet that needs to be updated", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "$ref" : "#/components/schemas/updatePetWithForm_request" - } - } - } - }, - "responses" : { - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Updates a pet in the store with form data", - "tags" : [ "pet" ] - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "description" : "", - "operationId" : "uploadFile", - "parameters" : [ { - "description" : "ID of pet to update", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "requestBody" : { - "content" : { - "multipart/form-data" : { - "schema" : { - "$ref" : "#/components/schemas/uploadFile_request" - } - } - } - }, - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ApiResponse" - } - } - }, - "description" : "successful operation" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "uploads an image", - "tags" : [ "pet" ] - } - }, - "/store/inventory" : { - "get" : { - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "additionalProperties" : { - "format" : "int32", - "type" : "integer" - }, - "type" : "object" - } - } - }, - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Returns pet inventories by status", - "tags" : [ "store" ] - } - }, - "/store/order" : { - "post" : { - "description" : "", - "operationId" : "placeOrder", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "order placed for purchasing the pet", - "required" : true - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid Order" - } - }, - "summary" : "Place an order for a pet", - "tags" : [ "store" ] - } - }, - "/store/order/{orderId}" : { - "delete" : { - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "description" : "ID of the order that needs to be deleted", - "explode" : false, - "in" : "path", - "name" : "orderId", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Order not found" - } - }, - "summary" : "Delete purchase order by ID", - "tags" : [ "store" ] - }, - "get" : { - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", - "operationId" : "getOrderById", - "parameters" : [ { - "description" : "ID of pet that needs to be fetched", - "explode" : false, - "in" : "path", - "name" : "orderId", - "required" : true, - "schema" : { - "format" : "int64", - "maximum" : 5, - "minimum" : 1, - "type" : "integer" - }, - "style" : "simple" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Order not found" - } - }, - "summary" : "Find purchase order by ID", - "tags" : [ "store" ] - } - }, - "/user" : { - "post" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Created user object", - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Create user", - "tags" : [ "user" ] - } - }, - "/user/createWithArray" : { - "post" : { - "description" : "", - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Creates list of users with given input array", - "tags" : [ "user" ] - } - }, - "/user/createWithList" : { - "post" : { - "description" : "", - "operationId" : "createUsersWithListInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Creates list of users with given input array", - "tags" : [ "user" ] - } - }, - "/user/login" : { - "get" : { - "description" : "", - "operationId" : "loginUser", - "parameters" : [ { - "description" : "The user name for login", - "explode" : true, - "in" : "query", - "name" : "username", - "required" : true, - "schema" : { - "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", - "type" : "string" - }, - "style" : "form" - }, { - "description" : "The password for login in clear text", - "explode" : true, - "in" : "query", - "name" : "password", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - }, - "description" : "successful operation", - "headers" : { - "Set-Cookie" : { - "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", - "explode" : false, - "schema" : { - "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", - "type" : "string" - }, - "style" : "simple" - }, - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "explode" : false, - "schema" : { - "format" : "int32", - "type" : "integer" - }, - "style" : "simple" - }, - "X-Expires-After" : { - "description" : "date in UTC when token expires", - "explode" : false, - "schema" : { - "format" : "date-time", - "type" : "string" - }, - "style" : "simple" - } - } - }, - "400" : { - "description" : "Invalid username/password supplied" - } - }, - "summary" : "Logs user into the system", - "tags" : [ "user" ] - } - }, - "/user/logout" : { - "get" : { - "description" : "", - "operationId" : "logoutUser", - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Logs out current logged in user session", - "tags" : [ "user" ] - } - }, - "/user/{username}" : { - "delete" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "description" : "The name that needs to be deleted", - "explode" : false, - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Delete user", - "tags" : [ "user" ] - }, - "get" : { - "description" : "", - "operationId" : "getUserByName", - "parameters" : [ { - "description" : "The name that needs to be fetched. Use user1 for testing.", - "explode" : false, - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - }, - "summary" : "Get user by user name", - "tags" : [ "user" ] - }, - "put" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "description" : "name that need to be deleted", - "explode" : false, - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Updated user object", - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid user supplied" - }, - "404" : { - "description" : "User not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Updated user", - "tags" : [ "user" ] - } - }, - "/fake/parameter_example_test" : { - "get" : { - "description" : "", - "operationId" : "fake_parameter_example_test", - "parameters" : [ { - "explode" : true, - "in" : "query", - "name" : "data", - "required" : true, - "schema" : { - "$ref" : "#/components/schemas/Pet" - }, - "style" : "form" - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "summary" : "fake endpoint to test parameter example (object)", - "tags" : [ "fake" ] - } - }, - "/fake/nullable_example_test" : { - "get" : { - "description" : "", - "operationId" : "fake_nullable_example_test", - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/TestNullable" - } - } - }, - "description" : "Successful operation" - } - }, - "summary" : "Fake endpoint to test nullable example (object)", - "tags" : [ "fake" ] - } - } - }, - "components" : { - "requestBodies" : { - "UserArray" : { - "content" : { - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/User" - }, - "type" : "array" - } - } - }, - "description" : "List of user object", - "required" : true - }, - "Pet" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "Pet object that needs to be added to the store", - "required" : true - } - }, - "schemas" : { - "TestEnum" : { - "enum" : [ "A", "B" ], - "type" : "string" - }, - "TestNullable" : { - "example" : { - "nullableName" : "nullableName", - "name" : "name" - }, - "properties" : { - "name" : { - "type" : "string" - }, - "nullableName" : { - "nullable" : true, - "type" : "string" - } - }, - "type" : "object" - }, - "Order" : { - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "petId" : { - "format" : "int64", - "type" : "integer" - }, - "quantity" : { - "format" : "int32", - "type" : "integer" - }, - "shipDate" : { - "format" : "date-time", - "type" : "string" - }, - "status" : { - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ], - "type" : "string" - }, - "complete" : { - "default" : false, - "type" : "boolean" - } - }, - "title" : "Pet Order", - "type" : "object", - "xml" : { - "name" : "Order" - } - }, - "Category" : { - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "name" : { - "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", - "type" : "string" - } - }, - "title" : "Pet category", - "type" : "object", - "xml" : { - "name" : "Category" - } - }, - "User" : { - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "description" : "User Status", - "format" : "int32", - "type" : "integer" - } - }, - "title" : "a User", - "type" : "object", - "xml" : { - "name" : "User" - } - }, - "Tag" : { - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "name" : { - "type" : "string" - } - }, - "title" : "Pet Tag", - "type" : "object", - "xml" : { - "name" : "Tag" - } - }, - "Pet" : { - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "example" : "doggie", - "type" : "string" - }, - "photoUrls" : { - "items" : { - "type" : "string" - }, - "type" : "array", - "xml" : { - "name" : "photoUrl", - "wrapped" : true - } - }, - "tags" : { - "items" : { - "$ref" : "#/components/schemas/Tag" - }, - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - } - }, - "status" : { - "deprecated" : true, - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ], - "type" : "string" - } - }, - "required" : [ "name", "photoUrls" ], - "title" : "a Pet", - "type" : "object", - "xml" : { - "name" : "Pet" - } - }, - "ApiResponse" : { - "description" : "Describes the result of uploading an image resource", - "example" : { - "code" : 0, - "type" : "type", - "message" : "message" - }, - "properties" : { - "code" : { - "format" : "int32", - "type" : "integer" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - }, - "title" : "An uploaded response", - "type" : "object" - }, - "Dog" : { - "allOf" : [ { - "$ref" : "#/components/schemas/Animal" - }, { - "properties" : { - "breed" : { - "type" : "string" - } - }, - "type" : "object" - } ] - }, - "Cat" : { - "allOf" : [ { - "$ref" : "#/components/schemas/Animal" - }, { - "properties" : { - "declawed" : { - "type" : "boolean" - } - }, - "type" : "object" - } ] - }, - "Animal" : { - "discriminator" : { - "mapping" : { - "DOG" : "#/components/schemas/Dog", - "CAT" : "#/components/schemas/Cat" - }, - "propertyName" : "className" - }, - "properties" : { - "className" : { - "type" : "string" - }, - "color" : { - "default" : "red", - "type" : "string" - } - }, - "required" : [ "className" ], - "type" : "object" - }, - "updatePetWithForm_request" : { - "properties" : { - "name" : { - "description" : "Updated name of the pet", - "type" : "string" - }, - "status" : { - "description" : "Updated status of the pet", - "type" : "string" - } - }, - "type" : "object" - }, - "uploadFile_request" : { - "properties" : { - "additionalMetadata" : { - "description" : "Additional data to pass to server", - "type" : "string" - }, - "file" : { - "description" : "file to upload", - "format" : "binary", - "type" : "string" - } - }, - "type" : "object" - } - }, - "securitySchemes" : { - "petstore_auth" : { - "flows" : { - "implicit" : { - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - }, - "type" : "oauth2" - }, - "api_key" : { - "in" : "header", - "name" : "api_key", - "type" : "apiKey" - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj index e69de29bb2d1..99b5e849d995 100644 --- a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Org.OpenAPITools.csproj @@ -0,0 +1,27 @@ + + + A library generated from a OpenAPI doc + No Copyright + OpenAPI + net8.0 + true + true + 1.0.0 + Org.OpenAPITools + Org.OpenAPITools + cb87e868-8646-48ef-9bb6-344b537d0d37 + Linux + ..\.. + + + + + + + + + + + + + diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json index b47dce3d2c68..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -1,1203 +0,0 @@ -{ - "openapi" : "3.0.0", - "info" : { - "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", - "license" : { - "name" : "Apache-2.0", - "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" - }, - "title" : "OpenAPI Petstore", - "version" : "1.0.0" - }, - "externalDocs" : { - "description" : "Find out more about Swagger", - "url" : "http://swagger.io" - }, - "servers" : [ { - "url" : "http://petstore.swagger.io/v2" - } ], - "tags" : [ { - "description" : "Everything about your Pets", - "name" : "pet" - }, { - "description" : "Access to Petstore orders", - "name" : "store" - }, { - "description" : "Operations about user", - "name" : "user" - } ], - "paths" : { - "/test" : { - "get" : { - "parameters" : [ { - "explode" : true, - "in" : "query", - "name" : "testQuery", - "required" : false, - "schema" : { - "$ref" : "#/components/schemas/TestEnum" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "description" : "OK" - } - }, - "summary" : "Test API" - } - }, - "/pet" : { - "post" : { - "description" : "", - "operationId" : "addPet", - "requestBody" : { - "$ref" : "#/components/requestBodies/Pet" - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Add a new pet to the store", - "tags" : [ "pet" ] - }, - "put" : { - "description" : "", - "operationId" : "updatePet", - "requestBody" : { - "$ref" : "#/components/requestBodies/Pet" - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Pet not found" - }, - "405" : { - "description" : "Validation exception" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Update an existing pet", - "tags" : [ "pet" ] - } - }, - "/pet/findByStatus" : { - "get" : { - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findPetsByStatus", - "parameters" : [ { - "deprecated" : true, - "description" : "Status values that need to be considered for filter", - "explode" : false, - "in" : "query", - "name" : "status", - "required" : true, - "schema" : { - "items" : { - "default" : "available", - "enum" : [ "available", "pending", "sold" ], - "type" : "string" - }, - "type" : "array" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - }, - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid status value" - } - }, - "security" : [ { - "petstore_auth" : [ "read:pets" ] - } ], - "summary" : "Finds Pets by status", - "tags" : [ "pet" ] - } - }, - "/pet/findByTags" : { - "get" : { - "deprecated" : true, - "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "parameters" : [ { - "description" : "Tags to filter by", - "explode" : false, - "in" : "query", - "name" : "tags", - "required" : true, - "schema" : { - "items" : { - "type" : "string" - }, - "type" : "array" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - }, - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid tag value" - } - }, - "security" : [ { - "petstore_auth" : [ "read:pets" ] - } ], - "summary" : "Finds Pets by tags", - "tags" : [ "pet" ] - } - }, - "/pet/{petId}" : { - "delete" : { - "description" : "", - "operationId" : "deletePet", - "parameters" : [ { - "explode" : false, - "in" : "header", - "name" : "api_key", - "required" : false, - "schema" : { - "type" : "string" - }, - "style" : "simple" - }, { - "description" : "Pet id to delete", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "responses" : { - "400" : { - "description" : "Invalid pet value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Deletes a pet", - "tags" : [ "pet" ] - }, - "get" : { - "description" : "Returns a single pet", - "operationId" : "getPetById", - "parameters" : [ { - "description" : "ID of pet to return", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Pet not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Find pet by ID", - "tags" : [ "pet" ] - }, - "post" : { - "description" : "", - "operationId" : "updatePetWithForm", - "parameters" : [ { - "description" : "ID of pet that needs to be updated", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "$ref" : "#/components/schemas/updatePetWithForm_request" - } - } - } - }, - "responses" : { - "405" : { - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Updates a pet in the store with form data", - "tags" : [ "pet" ] - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "description" : "", - "operationId" : "uploadFile", - "parameters" : [ { - "description" : "ID of pet to update", - "explode" : false, - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - }, - "style" : "simple" - } ], - "requestBody" : { - "content" : { - "multipart/form-data" : { - "schema" : { - "$ref" : "#/components/schemas/uploadFile_request" - } - } - } - }, - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ApiResponse" - } - } - }, - "description" : "successful operation" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "uploads an image", - "tags" : [ "pet" ] - } - }, - "/store/inventory" : { - "get" : { - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "additionalProperties" : { - "format" : "int32", - "type" : "integer" - }, - "type" : "object" - } - } - }, - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Returns pet inventories by status", - "tags" : [ "store" ] - } - }, - "/store/order" : { - "post" : { - "description" : "", - "operationId" : "placeOrder", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "order placed for purchasing the pet", - "required" : true - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid Order" - } - }, - "summary" : "Place an order for a pet", - "tags" : [ "store" ] - } - }, - "/store/order/{orderId}" : { - "delete" : { - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "description" : "ID of the order that needs to be deleted", - "explode" : false, - "in" : "path", - "name" : "orderId", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Order not found" - } - }, - "summary" : "Delete purchase order by ID", - "tags" : [ "store" ] - }, - "get" : { - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", - "operationId" : "getOrderById", - "parameters" : [ { - "description" : "ID of pet that needs to be fetched", - "explode" : false, - "in" : "path", - "name" : "orderId", - "required" : true, - "schema" : { - "format" : "int64", - "maximum" : 5, - "minimum" : 1, - "type" : "integer" - }, - "style" : "simple" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid ID supplied" - }, - "404" : { - "description" : "Order not found" - } - }, - "summary" : "Find purchase order by ID", - "tags" : [ "store" ] - } - }, - "/user" : { - "post" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Created user object", - "required" : true - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Create user", - "tags" : [ "user" ] - } - }, - "/user/createWithArray" : { - "post" : { - "description" : "", - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Creates list of users with given input array", - "tags" : [ "user" ] - } - }, - "/user/createWithList" : { - "post" : { - "description" : "", - "operationId" : "createUsersWithListInput", - "requestBody" : { - "$ref" : "#/components/requestBodies/UserArray" - }, - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Creates list of users with given input array", - "tags" : [ "user" ] - } - }, - "/user/login" : { - "get" : { - "description" : "", - "operationId" : "loginUser", - "parameters" : [ { - "description" : "The user name for login", - "explode" : true, - "in" : "query", - "name" : "username", - "required" : true, - "schema" : { - "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", - "type" : "string" - }, - "style" : "form" - }, { - "description" : "The password for login in clear text", - "explode" : true, - "in" : "query", - "name" : "password", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - }, - "description" : "successful operation", - "headers" : { - "Set-Cookie" : { - "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", - "explode" : false, - "schema" : { - "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", - "type" : "string" - }, - "style" : "simple" - }, - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "explode" : false, - "schema" : { - "format" : "int32", - "type" : "integer" - }, - "style" : "simple" - }, - "X-Expires-After" : { - "description" : "date in UTC when token expires", - "explode" : false, - "schema" : { - "format" : "date-time", - "type" : "string" - }, - "style" : "simple" - } - } - }, - "400" : { - "description" : "Invalid username/password supplied" - } - }, - "summary" : "Logs user into the system", - "tags" : [ "user" ] - } - }, - "/user/logout" : { - "get" : { - "description" : "", - "operationId" : "logoutUser", - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Logs out current logged in user session", - "tags" : [ "user" ] - } - }, - "/user/{username}" : { - "delete" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "description" : "The name that needs to be deleted", - "explode" : false, - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Delete user", - "tags" : [ "user" ] - }, - "get" : { - "description" : "", - "operationId" : "getUserByName", - "parameters" : [ { - "description" : "The name that needs to be fetched. Use user1 for testing.", - "explode" : false, - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "description" : "Invalid username supplied" - }, - "404" : { - "description" : "User not found" - } - }, - "summary" : "Get user by user name", - "tags" : [ "user" ] - }, - "put" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "description" : "name that need to be deleted", - "explode" : false, - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - }, - "style" : "simple" - } ], - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Updated user object", - "required" : true - }, - "responses" : { - "400" : { - "description" : "Invalid user supplied" - }, - "404" : { - "description" : "User not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Updated user", - "tags" : [ "user" ] - } - }, - "/fake/parameter_example_test" : { - "get" : { - "description" : "", - "operationId" : "fake_parameter_example_test", - "parameters" : [ { - "explode" : true, - "in" : "query", - "name" : "data", - "required" : true, - "schema" : { - "$ref" : "#/components/schemas/Pet" - }, - "style" : "form" - } ], - "responses" : { - "default" : { - "description" : "successful operation" - } - }, - "summary" : "fake endpoint to test parameter example (object)", - "tags" : [ "fake" ] - } - }, - "/fake/nullable_example_test" : { - "get" : { - "description" : "", - "operationId" : "fake_nullable_example_test", - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/TestNullable" - } - } - }, - "description" : "Successful operation" - } - }, - "summary" : "Fake endpoint to test nullable example (object)", - "tags" : [ "fake" ] - } - } - }, - "components" : { - "requestBodies" : { - "UserArray" : { - "content" : { - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/User" - }, - "type" : "array" - } - } - }, - "description" : "List of user object", - "required" : true - }, - "Pet" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "Pet object that needs to be added to the store", - "required" : true - } - }, - "schemas" : { - "TestEnum" : { - "enum" : [ "A", "B" ], - "type" : "string" - }, - "TestNullable" : { - "example" : { - "nullableName" : "nullableName", - "name" : "name" - }, - "properties" : { - "name" : { - "type" : "string" - }, - "nullableName" : { - "nullable" : true, - "type" : "string" - } - }, - "type" : "object" - }, - "Order" : { - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "petId" : { - "format" : "int64", - "type" : "integer" - }, - "quantity" : { - "format" : "int32", - "type" : "integer" - }, - "shipDate" : { - "format" : "date-time", - "type" : "string" - }, - "status" : { - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ], - "type" : "string" - }, - "complete" : { - "default" : false, - "type" : "boolean" - } - }, - "title" : "Pet Order", - "type" : "object", - "xml" : { - "name" : "Order" - } - }, - "Category" : { - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "name" : { - "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", - "type" : "string" - } - }, - "title" : "Pet category", - "type" : "object", - "xml" : { - "name" : "Category" - } - }, - "User" : { - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "description" : "User Status", - "format" : "int32", - "type" : "integer" - } - }, - "title" : "a User", - "type" : "object", - "xml" : { - "name" : "User" - } - }, - "Tag" : { - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "name" : { - "type" : "string" - } - }, - "title" : "Pet Tag", - "type" : "object", - "xml" : { - "name" : "Tag" - } - }, - "Pet" : { - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "example" : "doggie", - "type" : "string" - }, - "photoUrls" : { - "items" : { - "type" : "string" - }, - "type" : "array", - "xml" : { - "name" : "photoUrl", - "wrapped" : true - } - }, - "tags" : { - "items" : { - "$ref" : "#/components/schemas/Tag" - }, - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - } - }, - "status" : { - "deprecated" : true, - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ], - "type" : "string" - } - }, - "required" : [ "name", "photoUrls" ], - "title" : "a Pet", - "type" : "object", - "xml" : { - "name" : "Pet" - } - }, - "ApiResponse" : { - "description" : "Describes the result of uploading an image resource", - "example" : { - "code" : 0, - "type" : "type", - "message" : "message" - }, - "properties" : { - "code" : { - "format" : "int32", - "type" : "integer" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - }, - "title" : "An uploaded response", - "type" : "object" - }, - "Dog" : { - "allOf" : [ { - "$ref" : "#/components/schemas/Animal" - }, { - "properties" : { - "breed" : { - "type" : "string" - } - }, - "type" : "object" - } ] - }, - "Cat" : { - "allOf" : [ { - "$ref" : "#/components/schemas/Animal" - }, { - "properties" : { - "declawed" : { - "type" : "boolean" - } - }, - "type" : "object" - } ] - }, - "Animal" : { - "discriminator" : { - "mapping" : { - "DOG" : "#/components/schemas/Dog", - "CAT" : "#/components/schemas/Cat" - }, - "propertyName" : "className" - }, - "properties" : { - "className" : { - "type" : "string" - }, - "color" : { - "default" : "red", - "type" : "string" - } - }, - "required" : [ "className" ], - "type" : "object" - }, - "updatePetWithForm_request" : { - "properties" : { - "name" : { - "description" : "Updated name of the pet", - "type" : "string" - }, - "status" : { - "description" : "Updated status of the pet", - "type" : "string" - } - }, - "type" : "object" - }, - "uploadFile_request" : { - "properties" : { - "additionalMetadata" : { - "description" : "Additional data to pass to server", - "type" : "string" - }, - "file" : { - "description" : "file to upload", - "format" : "binary", - "type" : "string" - } - }, - "type" : "object" - } - }, - "securitySchemes" : { - "petstore_auth" : { - "flows" : { - "implicit" : { - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - }, - "type" : "oauth2" - }, - "api_key" : { - "in" : "header", - "name" : "api_key", - "type" : "apiKey" - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Dockerfile b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Dockerfile index e69de29bb2d1..c24f45dbc5a4 100644 --- a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Dockerfile +++ b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +# Container we use for final publish +FROM mcr.microsoft.com/dotnet/core/aspnet:8.0-buster-slim AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +# Build container +FROM mcr.microsoft.com/dotnet/core/sdk:8.0-buster AS build + +# Copy the code into the container +WORKDIR /src +COPY ["src/Org.OpenAPITools/Org.OpenAPITools.csproj", "Org.OpenAPITools/"] + +# NuGet restore +RUN dotnet restore "Org.OpenAPITools/Org.OpenAPITools.csproj" +COPY ["src/Org.OpenAPITools/", "Org.OpenAPITools/"] + +# Build the API +WORKDIR "Org.OpenAPITools" +RUN dotnet build "Org.OpenAPITools.csproj" -c Release -o /app/build + +# Publish it +FROM build AS publish +RUN dotnet publish "Org.OpenAPITools.csproj" -c Release -o /app/publish + +# Make the final image for publishing +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"] diff --git a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs index e69de29bb2d1..18796da30fcb 100644 --- a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Formatters/InputFormatterStream.cs @@ -0,0 +1,45 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System; +using System.IO; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.Formatters; + +namespace Org.OpenAPITools.Formatters +{ + /// + public class InputFormatterStream : InputFormatter + { + /// + public InputFormatterStream() + { + SupportedMediaTypes.Add("application/octet-stream"); + SupportedMediaTypes.Add("image/jpeg"); + } + + /// + public override Task ReadRequestBodyAsync(InputFormatterContext context) + { + return InputFormatterResult.SuccessAsync(context.HttpContext.Request.Body); + } + + /// + protected override bool CanReadType(Type type) + { + if (type == typeof(Stream)) + { + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec index e69de29bb2d1..b1d83a359618 100644 --- a/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec +++ b/samples/server/petstore/aspnetcore-8.0-useSwashBuckle/src/Org.OpenAPITools/Org.OpenAPITools.nuspec @@ -0,0 +1,20 @@ + + + + $id$ + 1.0.0 + OpenAPI Library + OpenAPI + OpenAPI + https://www.apache.org/licenses/LICENSE-2.0.html + + false + A library generated from a OpenAPI doc + Summary of changes made in this release of the package. + No Copyright + Org.OpenAPITools + + diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index 9eccd5c317f6..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -1,107 +0,0 @@ -/* - * OpenAPI Petstore - * - * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. - * - * The version of the OpenAPI document: 1.0.0 - * - * Generated by: https://openapi-generator.tech - */ - -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; - -namespace Org.OpenAPITools.Filters -{ - /// - /// Path Parameter Validation Rules Filter - /// - public class GeneratePathParamsValidationFilter : IOperationFilter - { - /// - /// Constructor - /// - /// Operation - /// OperationFilterContext - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var pars = context.ApiDescription.ParameterDescriptions; - - foreach (var par in pars) - { - var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); - - var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); - - // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 - // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 - // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema - if (attributes.Any() && openapiParam != null) - { - // Required - [Required] - var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); - if (requiredAttr != null) - { - openapiParam.Required = true; - } - - // Regex Pattern [RegularExpression] - var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); - if (regexAttr != null) - { - var regex = (string)regexAttr.ConstructorArguments[0].Value; - openapiParam.Schema.Pattern = regex; - } - - // String Length [StringLength] - int? minLength = null, maxLength = null; - var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); - if (stringLengthAttr != null) - { - if (stringLengthAttr.NamedArguments.Count == 1) - { - minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; - } - maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; - } - - var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); - if (minLengthAttr != null) - { - minLength = (int)minLengthAttr.ConstructorArguments[0].Value; - } - - var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); - if (maxLengthAttr != null) - { - maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; - } - - if (minLength != null) - { - openapiParam.Schema.MinLength = minLength; - } - - if (maxLength != null) - { - openapiParam.Schema.MaxLength = maxLength; - } - - // Range [Range] - var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); - if (rangeAttr != null) - { - var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; - var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; - - openapiParam.Schema.MinLength = rangeMin; - openapiParam.Schema.MaxLength = rangeMax; - } - } - } - } - } -} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs index e69de29bb2d1..00ed16ed6758 100644 --- a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Program.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Org.OpenAPITools +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + /// + /// Create the host builder. + /// + /// + /// IHostBuilder + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup() + .UseUrls("http://0.0.0.0:8080/"); + }); + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json index e69de29bb2d1..def9159a7d94 100644 --- a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/appsettings.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Properties/launchSettings.json b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Properties/launchSettings.json index e69de29bb2d1..1b527df2c2b3 100644 --- a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Properties/launchSettings.json +++ b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:61788", + "sslPort": 44301 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "WebApplication1": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json index 333dcf2bfceb..e69de29bb2d1 100644 --- a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json +++ b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -1,1021 +0,0 @@ -{ - "openapi" : "3.0.1", - "info" : { - "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", - "license" : { - "name" : "Apache-2.0", - "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" - }, - "title" : "OpenAPI Petstore", - "version" : "1.0.0" - }, - "servers" : [ { - "url" : "http://petstore.swagger.io/v2" - } ], - "tags" : [ { - "description" : "Everything about your Pets", - "name" : "pet" - }, { - "description" : "Access to Petstore orders", - "name" : "store" - }, { - "description" : "Operations about user", - "name" : "user" - } ], - "paths" : { - "/pet" : { - "post" : { - "operationId" : "addPet", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "Pet object that needs to be added to the store", - "required" : true - }, - "responses" : { - "405" : { - "content" : { }, - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Add a new pet to the store", - "tags" : [ "pet" ], - "x-codegen-request-body-name" : "body" - }, - "put" : { - "operationId" : "updatePet", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "Pet object that needs to be added to the store", - "required" : true - }, - "responses" : { - "400" : { - "content" : { }, - "description" : "Invalid ID supplied" - }, - "404" : { - "content" : { }, - "description" : "Pet not found" - }, - "405" : { - "content" : { }, - "description" : "Validation exception" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Update an existing pet", - "tags" : [ "pet" ], - "x-codegen-request-body-name" : "body" - } - }, - "/pet/findByStatus" : { - "get" : { - "description" : "Multiple status values can be provided with comma separated strings", - "operationId" : "findPetsByStatus", - "parameters" : [ { - "description" : "Status values that need to be considered for filter", - "explode" : false, - "in" : "query", - "name" : "status", - "required" : true, - "schema" : { - "items" : { - "default" : "available", - "enum" : [ "available", "pending", "sold" ], - "type" : "string" - }, - "type" : "array" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - }, - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "content" : { }, - "description" : "Invalid status value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Finds Pets by status", - "tags" : [ "pet" ] - } - }, - "/pet/findByTags" : { - "get" : { - "deprecated" : true, - "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "operationId" : "findPetsByTags", - "parameters" : [ { - "description" : "Tags to filter by", - "explode" : false, - "in" : "query", - "name" : "tags", - "required" : true, - "schema" : { - "items" : { - "type" : "string" - }, - "type" : "array" - }, - "style" : "form" - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - }, - "application/json" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/Pet" - }, - "type" : "array" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "content" : { }, - "description" : "Invalid tag value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Finds Pets by tags", - "tags" : [ "pet" ] - } - }, - "/pet/{petId}" : { - "delete" : { - "operationId" : "deletePet", - "parameters" : [ { - "in" : "header", - "name" : "api_key", - "schema" : { - "type" : "string" - } - }, { - "description" : "Pet id to delete", - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - } - } ], - "responses" : { - "400" : { - "content" : { }, - "description" : "Invalid pet value" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Deletes a pet", - "tags" : [ "pet" ] - }, - "get" : { - "description" : "Returns a single pet", - "operationId" : "getPetById", - "parameters" : [ { - "description" : "ID of pet to return", - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - } - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Pet" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "content" : { }, - "description" : "Invalid ID supplied" - }, - "404" : { - "content" : { }, - "description" : "Pet not found" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Find pet by ID", - "tags" : [ "pet" ] - }, - "post" : { - "operationId" : "updatePetWithForm", - "parameters" : [ { - "description" : "ID of pet that needs to be updated", - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - } - } ], - "requestBody" : { - "content" : { - "application/x-www-form-urlencoded" : { - "schema" : { - "$ref" : "#/components/schemas/updatePetWithForm_request" - } - } - } - }, - "responses" : { - "405" : { - "content" : { }, - "description" : "Invalid input" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "Updates a pet in the store with form data", - "tags" : [ "pet" ] - } - }, - "/pet/{petId}/uploadImage" : { - "post" : { - "operationId" : "uploadFile", - "parameters" : [ { - "description" : "ID of pet to update", - "in" : "path", - "name" : "petId", - "required" : true, - "schema" : { - "format" : "int64", - "type" : "integer" - } - } ], - "requestBody" : { - "content" : { - "multipart/form-data" : { - "schema" : { - "$ref" : "#/components/schemas/uploadFile_request" - } - } - } - }, - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/ApiResponse" - } - } - }, - "description" : "successful operation" - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ], - "summary" : "uploads an image", - "tags" : [ "pet" ] - } - }, - "/store/inventory" : { - "get" : { - "description" : "Returns a map of status codes to quantities", - "operationId" : "getInventory", - "responses" : { - "200" : { - "content" : { - "application/json" : { - "schema" : { - "additionalProperties" : { - "format" : "int32", - "type" : "integer" - }, - "type" : "object" - } - } - }, - "description" : "successful operation" - } - }, - "security" : [ { - "api_key" : [ ] - } ], - "summary" : "Returns pet inventories by status", - "tags" : [ "store" ] - } - }, - "/store/order" : { - "post" : { - "operationId" : "placeOrder", - "requestBody" : { - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "order placed for purchasing the pet", - "required" : true - }, - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "content" : { }, - "description" : "Invalid Order" - } - }, - "summary" : "Place an order for a pet", - "tags" : [ "store" ], - "x-codegen-request-body-name" : "body" - } - }, - "/store/order/{orderId}" : { - "delete" : { - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "description" : "ID of the order that needs to be deleted", - "in" : "path", - "name" : "orderId", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "content" : { }, - "description" : "Invalid ID supplied" - }, - "404" : { - "content" : { }, - "description" : "Order not found" - } - }, - "summary" : "Delete purchase order by ID", - "tags" : [ "store" ] - }, - "get" : { - "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", - "operationId" : "getOrderById", - "parameters" : [ { - "description" : "ID of pet that needs to be fetched", - "in" : "path", - "name" : "orderId", - "required" : true, - "schema" : { - "format" : "int64", - "maximum" : 5, - "minimum" : 1, - "type" : "integer" - } - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/Order" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "content" : { }, - "description" : "Invalid ID supplied" - }, - "404" : { - "content" : { }, - "description" : "Order not found" - } - }, - "summary" : "Find purchase order by ID", - "tags" : [ "store" ] - } - }, - "/user" : { - "post" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "createUser", - "requestBody" : { - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Created user object", - "required" : true - }, - "responses" : { - "default" : { - "content" : { }, - "description" : "successful operation" - } - }, - "summary" : "Create user", - "tags" : [ "user" ], - "x-codegen-request-body-name" : "body" - } - }, - "/user/createWithArray" : { - "post" : { - "operationId" : "createUsersWithArrayInput", - "requestBody" : { - "content" : { - "*/*" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/User" - }, - "type" : "array" - } - } - }, - "description" : "List of user object", - "required" : true - }, - "responses" : { - "default" : { - "content" : { }, - "description" : "successful operation" - } - }, - "summary" : "Creates list of users with given input array", - "tags" : [ "user" ], - "x-codegen-request-body-name" : "body" - } - }, - "/user/createWithList" : { - "post" : { - "operationId" : "createUsersWithListInput", - "requestBody" : { - "content" : { - "*/*" : { - "schema" : { - "items" : { - "$ref" : "#/components/schemas/User" - }, - "type" : "array" - } - } - }, - "description" : "List of user object", - "required" : true - }, - "responses" : { - "default" : { - "content" : { }, - "description" : "successful operation" - } - }, - "summary" : "Creates list of users with given input array", - "tags" : [ "user" ], - "x-codegen-request-body-name" : "body" - } - }, - "/user/login" : { - "get" : { - "operationId" : "loginUser", - "parameters" : [ { - "description" : "The user name for login", - "in" : "query", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - } - }, { - "description" : "The password for login in clear text", - "in" : "query", - "name" : "password", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "type" : "string" - } - }, - "application/json" : { - "schema" : { - "type" : "string" - } - } - }, - "description" : "successful operation", - "headers" : { - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", - "schema" : { - "format" : "int32", - "type" : "integer" - } - }, - "X-Expires-After" : { - "description" : "date in UTC when token expires", - "schema" : { - "format" : "date-time", - "type" : "string" - } - } - } - }, - "400" : { - "content" : { }, - "description" : "Invalid username/password supplied" - } - }, - "summary" : "Logs user into the system", - "tags" : [ "user" ] - } - }, - "/user/logout" : { - "get" : { - "operationId" : "logoutUser", - "responses" : { - "default" : { - "content" : { }, - "description" : "successful operation" - } - }, - "summary" : "Logs out current logged in user session", - "tags" : [ "user" ] - } - }, - "/user/{username}" : { - "delete" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "description" : "The name that needs to be deleted", - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "content" : { }, - "description" : "Invalid username supplied" - }, - "404" : { - "content" : { }, - "description" : "User not found" - } - }, - "summary" : "Delete user", - "tags" : [ "user" ] - }, - "get" : { - "operationId" : "getUserByName", - "parameters" : [ { - "description" : "The name that needs to be fetched. Use user1 for testing.", - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "content" : { - "application/xml" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - }, - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "successful operation" - }, - "400" : { - "content" : { }, - "description" : "Invalid username supplied" - }, - "404" : { - "content" : { }, - "description" : "User not found" - } - }, - "summary" : "Get user by user name", - "tags" : [ "user" ] - }, - "put" : { - "description" : "This can only be done by the logged in user.", - "operationId" : "updateUser", - "parameters" : [ { - "description" : "name that need to be deleted", - "in" : "path", - "name" : "username", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/User" - } - } - }, - "description" : "Updated user object", - "required" : true - }, - "responses" : { - "400" : { - "content" : { }, - "description" : "Invalid user supplied" - }, - "404" : { - "content" : { }, - "description" : "User not found" - } - }, - "summary" : "Updated user", - "tags" : [ "user" ], - "x-codegen-request-body-name" : "body" - } - } - }, - "components" : { - "schemas" : { - "Order" : { - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "petId" : { - "format" : "int64", - "type" : "integer" - }, - "quantity" : { - "format" : "int32", - "type" : "integer" - }, - "shipDate" : { - "format" : "date-time", - "type" : "string" - }, - "status" : { - "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ], - "type" : "string" - }, - "complete" : { - "default" : false, - "type" : "boolean" - } - }, - "title" : "Pet Order", - "type" : "object", - "xml" : { - "name" : "Order" - } - }, - "Category" : { - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "name" : { - "type" : "string" - } - }, - "title" : "Pet category", - "type" : "object", - "xml" : { - "name" : "Category" - } - }, - "User" : { - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "username" : { - "type" : "string" - }, - "firstName" : { - "type" : "string" - }, - "lastName" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "password" : { - "type" : "string" - }, - "phone" : { - "type" : "string" - }, - "userStatus" : { - "description" : "User Status", - "format" : "int32", - "type" : "integer" - } - }, - "title" : "a User", - "type" : "object", - "xml" : { - "name" : "User" - } - }, - "Tag" : { - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "name" : { - "type" : "string" - } - }, - "title" : "Pet Tag", - "type" : "object", - "xml" : { - "name" : "Tag" - } - }, - "Pet" : { - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, - "properties" : { - "id" : { - "format" : "int64", - "type" : "integer" - }, - "category" : { - "$ref" : "#/components/schemas/Category" - }, - "name" : { - "example" : "doggie", - "type" : "string" - }, - "photoUrls" : { - "items" : { - "type" : "string" - }, - "type" : "array", - "xml" : { - "name" : "photoUrl", - "wrapped" : true - } - }, - "tags" : { - "items" : { - "$ref" : "#/components/schemas/Tag" - }, - "type" : "array", - "xml" : { - "name" : "tag", - "wrapped" : true - } - }, - "status" : { - "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ], - "type" : "string" - } - }, - "required" : [ "name", "photoUrls" ], - "title" : "a Pet", - "type" : "object", - "xml" : { - "name" : "Pet" - } - }, - "ApiResponse" : { - "description" : "Describes the result of uploading an image resource", - "example" : { - "code" : 0, - "type" : "type", - "message" : "message" - }, - "properties" : { - "code" : { - "format" : "int32", - "type" : "integer" - }, - "type" : { - "type" : "string" - }, - "message" : { - "type" : "string" - } - }, - "title" : "An uploaded response", - "type" : "object" - }, - "updatePetWithForm_request" : { - "properties" : { - "name" : { - "description" : "Updated name of the pet", - "type" : "string" - }, - "status" : { - "description" : "Updated status of the pet", - "type" : "string" - } - }, - "type" : "object" - }, - "uploadFile_request" : { - "properties" : { - "additionalMetadata" : { - "description" : "Additional data to pass to server", - "type" : "string" - }, - "file" : { - "description" : "file to upload", - "format" : "binary", - "type" : "string" - } - }, - "type" : "object" - } - }, - "securitySchemes" : { - "petstore_auth" : { - "flows" : { - "implicit" : { - "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", - "scopes" : { - "write:pets" : "modify pets in your account", - "read:pets" : "read your pets" - } - } - }, - "type" : "oauth2" - }, - "api_key" : { - "in" : "header", - "name" : "api_key", - "type" : "apiKey" - } - } - }, - "x-original-swagger-version" : "2.0" -} diff --git a/samples/server/petstore/cpp-oatpp/model/Order.hpp b/samples/server/petstore/cpp-oatpp/model/Order.hpp index 3f69abb6a203..e69de29bb2d1 100644 --- a/samples/server/petstore/cpp-oatpp/model/Order.hpp +++ b/samples/server/petstore/cpp-oatpp/model/Order.hpp @@ -1,59 +0,0 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* 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. -*/ -/* - * Order.h - * - * An order for a pets from the pet store - */ - -#ifndef Order_H_ -#define Order_H_ - - -#include "oatpp/core/macro/codegen.hpp" -#include "oatpp/core/Types.hpp" - -namespace org::openapitools::server::model -{ - -/* Begin DTO code-generation */ -#include OATPP_CODEGEN_BEGIN(DTO) - -/** - * Message Data-Transfer-Object - */ -class Order : public oatpp::DTO { - - DTO_INIT(Order, DTO /* Extends */) - - DTO_FIELD(oatpp::Int64, id); - DTO_FIELD(oatpp::Boolean, idIsSet); - DTO_FIELD(oatpp::Int64, petId); - DTO_FIELD(oatpp::Boolean, petIdIsSet); - DTO_FIELD(oatpp::Int32, quantity); - DTO_FIELD(oatpp::Boolean, quantityIsSet); - DTO_FIELD(oatpp::String, shipDate); - DTO_FIELD(oatpp::Boolean, shipDateIsSet); - DTO_FIELD(oatpp::String, status); - DTO_FIELD(oatpp::Boolean, statusIsSet); - DTO_FIELD(oatpp::Boolean, complete); - DTO_FIELD(oatpp::Boolean, completeIsSet); - -}; - -/* End DTO code-generation */ -#include OATPP_CODEGEN_END(DTO) - - -} // namespace org::openapitools::server::model - -#endif /* Order_H_ */ diff --git a/samples/server/petstore/cpp-pistache-everything/model/Order.cpp b/samples/server/petstore/cpp-pistache-everything/model/Order.cpp index 459d6ee5d69a..e69de29bb2d1 100644 --- a/samples/server/petstore/cpp-pistache-everything/model/Order.cpp +++ b/samples/server/petstore/cpp-pistache-everything/model/Order.cpp @@ -1,251 +0,0 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* 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. -*/ - - -#include "Order.h" -#include "Helpers.h" - -#include - -namespace org::openapitools::server::model -{ - -Order::Order() -{ - m_Id = 0L; - m_IdIsSet = false; - m_PetId = 0L; - m_PetIdIsSet = false; - m_Quantity = 0; - m_QuantityIsSet = false; - m_ShipDate = ""; - m_ShipDateIsSet = false; - m_Status = ""; - m_StatusIsSet = false; - m_Complete = false; - m_CompleteIsSet = false; - -} - -void Order::validate() const -{ - std::stringstream msg; - if (!validate(msg)) - { - throw org::openapitools::server::helpers::ValidationException(msg.str()); - } -} - -bool Order::validate(std::stringstream& msg) const -{ - return validate(msg, ""); -} - -bool Order::validate(std::stringstream& msg, const std::string& pathPrefix) const -{ - bool success = true; - const std::string _pathPrefix = pathPrefix.empty() ? "Order" : pathPrefix; - - - return success; -} - -bool Order::operator==(const Order& rhs) const -{ - return - - - - ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && - - - ((!petIdIsSet() && !rhs.petIdIsSet()) || (petIdIsSet() && rhs.petIdIsSet() && getPetId() == rhs.getPetId())) && - - - ((!quantityIsSet() && !rhs.quantityIsSet()) || (quantityIsSet() && rhs.quantityIsSet() && getQuantity() == rhs.getQuantity())) && - - - ((!shipDateIsSet() && !rhs.shipDateIsSet()) || (shipDateIsSet() && rhs.shipDateIsSet() && getShipDate() == rhs.getShipDate())) && - - - ((!statusIsSet() && !rhs.statusIsSet()) || (statusIsSet() && rhs.statusIsSet() && getStatus() == rhs.getStatus())) && - - - ((!completeIsSet() && !rhs.completeIsSet()) || (completeIsSet() && rhs.completeIsSet() && isComplete() == rhs.isComplete())) - - ; -} - -bool Order::operator!=(const Order& rhs) const -{ - return !(*this == rhs); -} - -void to_json(nlohmann::json& j, const Order& o) -{ - j = nlohmann::json::object(); - if(o.idIsSet()) - j["id"] = o.m_Id; - if(o.petIdIsSet()) - j["petId"] = o.m_PetId; - if(o.quantityIsSet()) - j["quantity"] = o.m_Quantity; - if(o.shipDateIsSet()) - j["shipDate"] = o.m_ShipDate; - if(o.statusIsSet()) - j["status"] = o.m_Status; - if(o.completeIsSet()) - j["complete"] = o.m_Complete; - -} - -void from_json(const nlohmann::json& j, Order& o) -{ - if(j.find("id") != j.end()) - { - j.at("id").get_to(o.m_Id); - o.m_IdIsSet = true; - } - if(j.find("petId") != j.end()) - { - j.at("petId").get_to(o.m_PetId); - o.m_PetIdIsSet = true; - } - if(j.find("quantity") != j.end()) - { - j.at("quantity").get_to(o.m_Quantity); - o.m_QuantityIsSet = true; - } - if(j.find("shipDate") != j.end()) - { - j.at("shipDate").get_to(o.m_ShipDate); - o.m_ShipDateIsSet = true; - } - if(j.find("status") != j.end()) - { - j.at("status").get_to(o.m_Status); - o.m_StatusIsSet = true; - } - if(j.find("complete") != j.end()) - { - j.at("complete").get_to(o.m_Complete); - o.m_CompleteIsSet = true; - } - -} - -int64_t Order::getId() const -{ - return m_Id; -} -void Order::setId(int64_t const value) -{ - m_Id = value; - m_IdIsSet = true; -} -bool Order::idIsSet() const -{ - return m_IdIsSet; -} -void Order::unsetId() -{ - m_IdIsSet = false; -} -int64_t Order::getPetId() const -{ - return m_PetId; -} -void Order::setPetId(int64_t const value) -{ - m_PetId = value; - m_PetIdIsSet = true; -} -bool Order::petIdIsSet() const -{ - return m_PetIdIsSet; -} -void Order::unsetPetId() -{ - m_PetIdIsSet = false; -} -int32_t Order::getQuantity() const -{ - return m_Quantity; -} -void Order::setQuantity(int32_t const value) -{ - m_Quantity = value; - m_QuantityIsSet = true; -} -bool Order::quantityIsSet() const -{ - return m_QuantityIsSet; -} -void Order::unsetQuantity() -{ - m_QuantityIsSet = false; -} -std::string Order::getShipDate() const -{ - return m_ShipDate; -} -void Order::setShipDate(std::string const& value) -{ - m_ShipDate = value; - m_ShipDateIsSet = true; -} -bool Order::shipDateIsSet() const -{ - return m_ShipDateIsSet; -} -void Order::unsetShipDate() -{ - m_ShipDateIsSet = false; -} -std::string Order::getStatus() const -{ - return m_Status; -} -void Order::setStatus(std::string const& value) -{ - m_Status = value; - m_StatusIsSet = true; -} -bool Order::statusIsSet() const -{ - return m_StatusIsSet; -} -void Order::unsetStatus() -{ - m_StatusIsSet = false; -} -bool Order::isComplete() const -{ - return m_Complete; -} -void Order::setComplete(bool const value) -{ - m_Complete = value; - m_CompleteIsSet = true; -} -bool Order::completeIsSet() const -{ - return m_CompleteIsSet; -} -void Order::unsetComplete() -{ - m_CompleteIsSet = false; -} - - -} // namespace org::openapitools::server::model - diff --git a/samples/server/petstore/cpp-pistache-everything/model/Order.h b/samples/server/petstore/cpp-pistache-everything/model/Order.h index e69de29bb2d1..78a6c8805bbe 100644 --- a/samples/server/petstore/cpp-pistache-everything/model/Order.h +++ b/samples/server/petstore/cpp-pistache-everything/model/Order.h @@ -0,0 +1,124 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* 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. +*/ +/* + * Order.h + * + * An order for a pets from the pet store + */ + +#ifndef Order_H_ +#define Order_H_ + + +#include +#include + +namespace org::openapitools::server::model +{ + +/// +/// An order for a pets from the pet store +/// +class Order +{ +public: + Order(); + virtual ~Order() = default; + + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + /// + /// Helper overload for validate. Used when one model stores another model and calls it's validate. + /// Not meant to be called outside that case. + /// + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; + + bool operator==(const Order& rhs) const; + bool operator!=(const Order& rhs) const; + + ///////////////////////////////////////////// + /// Order members + + /// + /// + /// + int64_t getId() const; + void setId(int64_t const value); + bool idIsSet() const; + void unsetId(); + /// + /// + /// + int64_t getPetId() const; + void setPetId(int64_t const value); + bool petIdIsSet() const; + void unsetPetId(); + /// + /// + /// + int32_t getQuantity() const; + void setQuantity(int32_t const value); + bool quantityIsSet() const; + void unsetQuantity(); + /// + /// + /// + std::string getShipDate() const; + void setShipDate(std::string const& value); + bool shipDateIsSet() const; + void unsetShipDate(); + /// + /// Order Status + /// + std::string getStatus() const; + void setStatus(std::string const& value); + bool statusIsSet() const; + void unsetStatus(); + /// + /// + /// + bool isComplete() const; + void setComplete(bool const value); + bool completeIsSet() const; + void unsetComplete(); + + friend void to_json(nlohmann::json& j, const Order& o); + friend void from_json(const nlohmann::json& j, Order& o); +protected: + int64_t m_Id; + bool m_IdIsSet; + int64_t m_PetId; + bool m_PetIdIsSet; + int32_t m_Quantity; + bool m_QuantityIsSet; + std::string m_ShipDate; + bool m_ShipDateIsSet; + std::string m_Status; + bool m_StatusIsSet; + bool m_Complete; + bool m_CompleteIsSet; + +}; + +} // namespace org::openapitools::server::model + +#endif /* Order_H_ */ diff --git a/samples/server/petstore/cpp-pistache-nested-schema-refs/api/StoreApi.cpp b/samples/server/petstore/cpp-pistache-nested-schema-refs/api/StoreApi.cpp index d23f51da8fd2..e69de29bb2d1 100644 --- a/samples/server/petstore/cpp-pistache-nested-schema-refs/api/StoreApi.cpp +++ b/samples/server/petstore/cpp-pistache-nested-schema-refs/api/StoreApi.cpp @@ -1,103 +0,0 @@ -/** -* Test swagger file -* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) -* -* 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. -*/ - -#include "StoreApi.h" -#include "Helpers.h" - -namespace org::openapitools::server::api -{ - -using namespace org::openapitools::server::helpers; -using namespace org::openapitools::server::model; - -const std::string StoreApi::base = ""; - -StoreApi::StoreApi(const std::shared_ptr& rtr) - : ApiBase(rtr) -{} - -void StoreApi::init() { - setupRoutes(); -} - -void StoreApi::setupRoutes() { - using namespace Pistache::Rest; - - Routes::Get(*router, base + "/pet", Routes::bind(&StoreApi::get_nested_object_handler, this)); - - // Default handler, called when a route is not found - router->addCustomHandler(Routes::bind(&StoreApi::store_api_default_handler, this)); -} - -void StoreApi::handleParsingException(const std::exception& ex, Pistache::Http::ResponseWriter &response) const noexcept { - std::pair codeAndError = handleParsingException(ex); - response.send(codeAndError.first, codeAndError.second); -} - -std::pair StoreApi::handleParsingException(const std::exception& ex) const noexcept { - try { - throw; - } catch (nlohmann::detail::exception &e) { - return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); - } catch (org::openapitools::server::helpers::ValidationException &e) { - return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); - } catch (std::exception &e) { - return std::make_pair(Pistache::Http::Code::Internal_Server_Error, e.what()); - } -} - -void StoreApi::handleOperationException(const std::exception& ex, Pistache::Http::ResponseWriter &response) const noexcept { - std::pair codeAndError = handleOperationException(ex); - response.send(codeAndError.first, codeAndError.second); -} - -std::pair StoreApi::handleOperationException(const std::exception& ex) const noexcept { - return std::make_pair(Pistache::Http::Code::Internal_Server_Error, ex.what()); -} - -void StoreApi::get_nested_object_handler(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response) { - try { - - - - - - - try { - - - - - - this->get_nested_object(response); - } catch (Pistache::Http::HttpError &e) { - response.send(static_cast(e.code()), e.what()); - return; - } catch (std::exception &e) { - this->handleOperationException(e, response); - return; - } - - } catch (std::exception &e) { - response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); - } - - -} - - -void StoreApi::store_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) { - response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist"); -} - -} // namespace org::openapitools::server::api - diff --git a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.cpp b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.cpp index e69de29bb2d1..f3cc1f8076b4 100644 --- a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.cpp +++ b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.cpp @@ -0,0 +1,94 @@ +/** +* Test swagger file +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* 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. +*/ + + +#include "OuterType.h" +#include "Helpers.h" + +#include + +namespace org::openapitools::server::model +{ + +OuterType::OuterType() +{ + +} + +void OuterType::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool OuterType::validate(std::stringstream& msg) const +{ + return validate(msg, ""); +} + +bool OuterType::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "OuterType" : pathPrefix; + + + if (!m_Middle.validate(msg, _pathPrefix + ".middle")) { + msg << _pathPrefix << ": Middle is invalid;"; + success = false; + } + return success; +} + +bool OuterType::operator==(const OuterType& rhs) const +{ + return + + + (getMiddle() == rhs.getMiddle()) + + + ; +} + +bool OuterType::operator!=(const OuterType& rhs) const +{ + return !(*this == rhs); +} + +void to_json(nlohmann::json& j, const OuterType& o) +{ + j = nlohmann::json::object(); + j["middle"] = o.m_Middle; + +} + +void from_json(const nlohmann::json& j, OuterType& o) +{ + j.at("middle").get_to(o.m_Middle); + +} + +org::openapitools::server::model::MiddleType OuterType::getMiddle() const +{ + return m_Middle; +} +void OuterType::setMiddle(org::openapitools::server::model::MiddleType const& value) +{ + m_Middle = value; +} + + +} // namespace org::openapitools::server::model + diff --git a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.h b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.h index e69de29bb2d1..df53df3c2be7 100644 --- a/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.h +++ b/samples/server/petstore/cpp-pistache-nested-schema-refs/model/OuterType.h @@ -0,0 +1,77 @@ +/** +* Test swagger file +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* 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. +*/ +/* + * OuterType.h + * + * + */ + +#ifndef OuterType_H_ +#define OuterType_H_ + + +#include "MiddleType.h" +#include + +namespace org::openapitools::server::model +{ + +/// +/// +/// +class OuterType +{ +public: + OuterType(); + virtual ~OuterType() = default; + + + /// + /// Validate the current data in the model. Throws a ValidationException on failure. + /// + void validate() const; + + /// + /// Validate the current data in the model. Returns false on error and writes an error + /// message into the given stringstream. + /// + bool validate(std::stringstream& msg) const; + + /// + /// Helper overload for validate. Used when one model stores another model and calls it's validate. + /// Not meant to be called outside that case. + /// + bool validate(std::stringstream& msg, const std::string& pathPrefix) const; + + bool operator==(const OuterType& rhs) const; + bool operator!=(const OuterType& rhs) const; + + ///////////////////////////////////////////// + /// OuterType members + + /// + /// + /// + org::openapitools::server::model::MiddleType getMiddle() const; + void setMiddle(org::openapitools::server::model::MiddleType const& value); + + friend void to_json(nlohmann::json& j, const OuterType& o); + friend void from_json(const nlohmann::json& j, OuterType& o); +protected: + org::openapitools::server::model::MiddleType m_Middle; + + +}; + +} // namespace org::openapitools::server::model + +#endif /* OuterType_H_ */ diff --git a/samples/server/petstore/cpp-pistache/model/Category.cpp b/samples/server/petstore/cpp-pistache/model/Category.cpp index 489c22157ada..e69de29bb2d1 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.cpp +++ b/samples/server/petstore/cpp-pistache/model/Category.cpp @@ -1,135 +0,0 @@ -/** -* OpenAPI Petstore -* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -* -* 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. -*/ - - -#include "Category.h" -#include "Helpers.h" - -#include - -namespace org::openapitools::server::model -{ - -Category::Category() -{ - m_Id = 0L; - m_IdIsSet = false; - m_Name = ""; - m_NameIsSet = false; - -} - -void Category::validate() const -{ - std::stringstream msg; - if (!validate(msg)) - { - throw org::openapitools::server::helpers::ValidationException(msg.str()); - } -} - -bool Category::validate(std::stringstream& msg) const -{ - return validate(msg, ""); -} - -bool Category::validate(std::stringstream& msg, const std::string& pathPrefix) const -{ - bool success = true; - const std::string _pathPrefix = pathPrefix.empty() ? "Category" : pathPrefix; - - - return success; -} - -bool Category::operator==(const Category& rhs) const -{ - return - - - - ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && - - - ((!nameIsSet() && !rhs.nameIsSet()) || (nameIsSet() && rhs.nameIsSet() && getName() == rhs.getName())) - - ; -} - -bool Category::operator!=(const Category& rhs) const -{ - return !(*this == rhs); -} - -void to_json(nlohmann::json& j, const Category& o) -{ - j = nlohmann::json::object(); - if(o.idIsSet()) - j["id"] = o.m_Id; - if(o.nameIsSet()) - j["name"] = o.m_Name; - -} - -void from_json(const nlohmann::json& j, Category& o) -{ - if(j.find("id") != j.end()) - { - j.at("id").get_to(o.m_Id); - o.m_IdIsSet = true; - } - if(j.find("name") != j.end()) - { - j.at("name").get_to(o.m_Name); - o.m_NameIsSet = true; - } - -} - -int64_t Category::getId() const -{ - return m_Id; -} -void Category::setId(int64_t const value) -{ - m_Id = value; - m_IdIsSet = true; -} -bool Category::idIsSet() const -{ - return m_IdIsSet; -} -void Category::unsetId() -{ - m_IdIsSet = false; -} -std::string Category::getName() const -{ - return m_Name; -} -void Category::setName(std::string const& value) -{ - m_Name = value; - m_NameIsSet = true; -} -bool Category::nameIsSet() const -{ - return m_NameIsSet; -} -void Category::unsetName() -{ - m_NameIsSet = false; -} - - -} // namespace org::openapitools::server::model - From 59e8dbce4178afee56224c41bbf9760223d0024d Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Fri, 13 Feb 2026 14:05:38 +0100 Subject: [PATCH 04/13] [FIX] model_generic.mustache to_json() formatting --- .../src/main/resources/python/model_generic.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index 42089bfa2c08..a423133d34a6 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -168,7 +168,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" From 9bfe0f70746e9ae317edd8a338c153154b6defb2 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Fri, 13 Feb 2026 15:15:04 +0100 Subject: [PATCH 05/13] apply scripts ./mvnw clean package -DskipTests ./bin/generate-samples.sh ./bin/configs/*.yaml ./bin/utils/export_docs_generators.sh --- docs/generators/crystal.md | 4 +- docs/generators/groovy.md | 2 + docs/generators/java-dubbo.md | 2 + docs/generators/java-helidon-client.md | 2 + docs/generators/java-helidon-server.md | 2 + docs/generators/java-inflector.md | 2 + docs/generators/java-micronaut-client.md | 2 + docs/generators/java-micronaut-server.md | 2 + docs/generators/java-microprofile.md | 2 + docs/generators/java-msf4j.md | 2 + docs/generators/java-pkmst.md | 2 + docs/generators/java-play-framework.md | 2 + docs/generators/java-undertow-server.md | 2 + docs/generators/java-vertx-web.md | 2 + docs/generators/java-vertx.md | 2 + docs/generators/java-wiremock.md | 2 + docs/generators/java.md | 2 + docs/generators/jaxrs-cxf-cdi.md | 2 + docs/generators/jaxrs-cxf-client.md | 2 + docs/generators/jaxrs-cxf-extended.md | 2 + docs/generators/jaxrs-cxf.md | 2 + docs/generators/jaxrs-jersey.md | 2 + docs/generators/jaxrs-resteasy-eap.md | 2 + docs/generators/jaxrs-resteasy.md | 2 + docs/generators/jaxrs-spec.md | 2 + docs/generators/kotlin-server.md | 7 +- docs/generators/kotlin-spring.md | 6 +- docs/generators/protobuf-schema.md | 1 + docs/generators/python-fastapi.md | 2 +- docs/generators/swift5.md | 2 +- docs/generators/typescript-angular.md | 4 +- docs/generators/typescript-axios.md | 2 +- docs/generators/typescript.md | 1 + .../docs/Bird.md | 8 +- .../docs/Category.md | 8 +- .../docs/DataQuery.md | 8 +- .../docs/DefaultValue.md | 8 +- .../docs/NumberPropertiesOnly.md | 8 +- .../docs/Pet.md | 8 +- .../docs/Query.md | 8 +- .../docs/Tag.md | 8 +- .../TestFormObjectMultipartRequestMarker.md | 8 +- ...lodeTrueObjectAllOfQueryObjectParameter.md | 8 +- ...lodeTrueArrayStringQueryObjectParameter.md | 8 +- .../openapi_client/models/bird.py | 66 +- .../openapi_client/models/category.py | 66 +- .../openapi_client/models/data_query.py | 69 +- .../openapi_client/models/default_value.py | 94 +- .../models/number_properties_only.py | 67 +- .../openapi_client/models/pet.py | 87 +- .../openapi_client/models/query.py | 55 +- .../openapi_client/models/tag.py | 66 +- ...st_form_object_multipart_request_marker.py | 65 +- ...ue_object_all_of_query_object_parameter.py | 68 +- ...rue_array_string_query_object_parameter.py | 65 +- samples/client/echo_api/python/docs/Bird.md | 8 +- .../client/echo_api/python/docs/Category.md | 8 +- .../client/echo_api/python/docs/DataQuery.md | 8 +- .../echo_api/python/docs/DefaultValue.md | 8 +- .../python/docs/NumberPropertiesOnly.md | 8 +- samples/client/echo_api/python/docs/Pet.md | 8 +- samples/client/echo_api/python/docs/Query.md | 8 +- samples/client/echo_api/python/docs/Tag.md | 8 +- .../TestFormObjectMultipartRequestMarker.md | 8 +- ...lodeTrueObjectAllOfQueryObjectParameter.md | 8 +- ...lodeTrueArrayStringQueryObjectParameter.md | 8 +- .../python/openapi_client/models/bird.py | 61 +- .../python/openapi_client/models/category.py | 61 +- .../openapi_client/models/data_query.py | 64 +- .../openapi_client/models/default_value.py | 89 +- .../models/number_properties_only.py | 62 +- .../python/openapi_client/models/pet.py | 82 +- .../python/openapi_client/models/query.py | 55 +- .../python/openapi_client/models/tag.py | 61 +- ...st_form_object_multipart_request_marker.py | 60 +- ...ue_object_all_of_query_object_parameter.py | 63 +- ...rue_array_string_query_object_parameter.py | 60 +- .../client/others/c/bearerAuth/model/object.c | 51 + samples/client/petstore/bash/docs/MapTest.md | 13 + samples/client/petstore/bash/docs/Name.md | 13 + .../petstore/c-useJsonUnformatted/model/pet.c | 335 +++++ samples/client/petstore/c/model/category.c | 113 ++ .../petstore/cpp-oatpp/api/StoreApi.hpp | 77 ++ .../client/PFXApiResponse.cpp | 160 +++ .../docs/AdditionalPropertiesAnyType.md | 8 +- .../docs/AdditionalPropertiesClass.md | 8 +- .../docs/AdditionalPropertiesObject.md | 8 +- ...AdditionalPropertiesWithDescriptionOnly.md | 8 +- .../python-aiohttp/docs/AllOfSuperModel.md | 8 +- .../python-aiohttp/docs/AllOfWithSingleRef.md | 8 +- .../petstore/python-aiohttp/docs/Animal.md | 8 +- .../python-aiohttp/docs/AnyOfColor.md | 8 +- .../petstore/python-aiohttp/docs/AnyOfPig.md | 8 +- .../docs/ArrayOfArrayOfModel.md | 8 +- .../docs/ArrayOfArrayOfNumberOnly.md | 8 +- .../python-aiohttp/docs/ArrayOfNumberOnly.md | 8 +- .../petstore/python-aiohttp/docs/ArrayTest.md | 8 +- .../python-aiohttp/docs/BaseDiscriminator.md | 8 +- .../petstore/python-aiohttp/docs/BasquePig.md | 8 +- .../petstore/python-aiohttp/docs/Bathing.md | 8 +- .../python-aiohttp/docs/Capitalization.md | 8 +- .../petstore/python-aiohttp/docs/Cat.md | 8 +- .../petstore/python-aiohttp/docs/Category.md | 8 +- .../python-aiohttp/docs/CircularAllOfRef.md | 8 +- .../docs/CircularReferenceModel.md | 8 +- .../python-aiohttp/docs/ClassModel.md | 8 +- .../petstore/python-aiohttp/docs/Client.md | 8 +- .../petstore/python-aiohttp/docs/Color.md | 8 +- .../petstore/python-aiohttp/docs/Creature.md | 8 +- .../python-aiohttp/docs/CreatureInfo.md | 8 +- .../petstore/python-aiohttp/docs/DanishPig.md | 8 +- .../python-aiohttp/docs/DeprecatedObject.md | 8 +- .../docs/DiscriminatorAllOfSub.md | 8 +- .../docs/DiscriminatorAllOfSuper.md | 8 +- .../petstore/python-aiohttp/docs/Dog.md | 8 +- .../python-aiohttp/docs/DummyModel.md | 8 +- .../python-aiohttp/docs/EnumArrays.md | 8 +- .../docs/EnumRefWithDefaultValue.md | 8 +- .../petstore/python-aiohttp/docs/EnumTest.md | 8 +- .../petstore/python-aiohttp/docs/Feeding.md | 8 +- .../petstore/python-aiohttp/docs/File.md | 8 +- .../docs/FileSchemaTestClass.md | 8 +- .../petstore/python-aiohttp/docs/FirstRef.md | 8 +- .../petstore/python-aiohttp/docs/Foo.md | 8 +- .../docs/FooGetDefaultResponse.md | 8 +- .../python-aiohttp/docs/FormatTest.md | 8 +- .../python-aiohttp/docs/HasOnlyReadOnly.md | 8 +- .../python-aiohttp/docs/HealthCheckResult.md | 8 +- .../python-aiohttp/docs/HuntingDog.md | 8 +- .../petstore/python-aiohttp/docs/Info.md | 8 +- .../docs/InnerDictWithProperty.md | 8 +- .../python-aiohttp/docs/InputAllOf.md | 8 +- .../python-aiohttp/docs/IntOrString.md | 8 +- .../petstore/python-aiohttp/docs/ListClass.md | 8 +- .../python-aiohttp/docs/MapOfArrayOfModel.md | 8 +- .../petstore/python-aiohttp/docs/MapTest.md | 8 +- ...dPropertiesAndAdditionalPropertiesClass.md | 8 +- .../python-aiohttp/docs/Model200Response.md | 8 +- .../python-aiohttp/docs/ModelApiResponse.md | 8 +- .../python-aiohttp/docs/ModelField.md | 8 +- .../python-aiohttp/docs/ModelReturn.md | 8 +- .../python-aiohttp/docs/MultiArrays.md | 8 +- .../petstore/python-aiohttp/docs/Name.md | 8 +- .../python-aiohttp/docs/NullableClass.md | 8 +- .../python-aiohttp/docs/NullableProperty.md | 8 +- .../python-aiohttp/docs/NumberOnly.md | 8 +- .../docs/ObjectToTestAdditionalProperties.md | 8 +- .../docs/ObjectWithDeprecatedFields.md | 8 +- .../petstore/python-aiohttp/docs/Order.md | 8 +- .../python-aiohttp/docs/OuterComposite.md | 8 +- .../docs/OuterObjectWithEnumProperty.md | 8 +- .../petstore/python-aiohttp/docs/Parent.md | 8 +- .../docs/ParentWithOptionalDict.md | 8 +- .../petstore/python-aiohttp/docs/Pet.md | 8 +- .../petstore/python-aiohttp/docs/Pig.md | 8 +- .../petstore/python-aiohttp/docs/PonySizes.md | 8 +- .../python-aiohttp/docs/PoopCleaning.md | 8 +- .../python-aiohttp/docs/PrimitiveString.md | 8 +- .../python-aiohttp/docs/PropertyMap.md | 8 +- .../docs/PropertyNameCollision.md | 8 +- .../python-aiohttp/docs/ReadOnlyFirst.md | 8 +- .../docs/SecondCircularAllOfRef.md | 8 +- .../petstore/python-aiohttp/docs/SecondRef.md | 8 +- .../python-aiohttp/docs/SelfReferenceModel.md | 8 +- .../python-aiohttp/docs/SpecialModelName.md | 8 +- .../python-aiohttp/docs/SpecialName.md | 8 +- .../petstore/python-aiohttp/docs/Tag.md | 8 +- .../petstore/python-aiohttp/docs/Task.md | 8 +- .../python-aiohttp/docs/TaskActivity.md | 8 +- .../TestErrorResponsesWithModel400Response.md | 8 +- .../TestErrorResponsesWithModel404Response.md | 8 +- ...lineFreeformAdditionalPropertiesRequest.md | 8 +- .../docs/TestModelWithEnumDefault.md | 8 +- ...ObjectForMultipartRequestsRequestMarker.md | 8 +- .../petstore/python-aiohttp/docs/Tiger.md | 8 +- ...edDictWithAdditionalModelListProperties.md | 8 +- ...dDictWithAdditionalStringListProperties.md | 8 +- ...leWithAdditionalPropertiesRequestObject.md | 8 +- .../petstore/python-aiohttp/docs/User.md | 8 +- .../python-aiohttp/docs/WithNestedOneOf.md | 8 +- .../models/additional_properties_any_type.py | 74 +- .../models/additional_properties_class.py | 61 +- .../models/additional_properties_object.py | 74 +- ...tional_properties_with_description_only.py | 74 +- .../petstore_api/models/all_of_super_model.py | 60 +- .../models/all_of_with_single_ref.py | 61 +- .../petstore_api/models/animal.py | 60 +- .../petstore_api/models/any_of_color.py | 139 +- .../petstore_api/models/any_of_pig.py | 116 +- .../models/array_of_array_of_model.py | 74 +- .../models/array_of_array_of_number_only.py | 60 +- .../models/array_of_number_only.py | 60 +- .../petstore_api/models/array_test.py | 77 +- .../petstore_api/models/base_discriminator.py | 60 +- .../petstore_api/models/basque_pig.py | 61 +- .../petstore_api/models/bathing.py | 74 +- .../petstore_api/models/capitalization.py | 65 +- .../python-aiohttp/petstore_api/models/cat.py | 62 +- .../petstore_api/models/category.py | 61 +- .../models/circular_all_of_ref.py | 70 +- .../models/circular_reference_model.py | 66 +- .../petstore_api/models/class_model.py | 60 +- .../petstore_api/models/client.py | 60 +- .../petstore_api/models/color.py | 147 +- .../petstore_api/models/creature.py | 63 +- .../petstore_api/models/creature_info.py | 60 +- .../petstore_api/models/danish_pig.py | 61 +- .../petstore_api/models/deprecated_object.py | 60 +- .../models/discriminator_all_of_sub.py | 60 +- .../models/discriminator_all_of_super.py | 58 +- .../python-aiohttp/petstore_api/models/dog.py | 62 +- .../petstore_api/models/dummy_model.py | 66 +- .../petstore_api/models/enum_arrays.py | 71 +- .../models/enum_ref_with_default_value.py | 60 +- .../petstore_api/models/enum_test.py | 116 +- .../petstore_api/models/feeding.py | 74 +- .../petstore_api/models/file.py | 60 +- .../models/file_schema_test_class.py | 73 +- .../petstore_api/models/first_ref.py | 66 +- .../python-aiohttp/petstore_api/models/foo.py | 60 +- .../models/foo_get_default_response.py | 65 +- .../petstore_api/models/format_test.py | 76 +- .../petstore_api/models/has_only_read_only.py | 67 +- .../models/health_check_result.py | 67 +- .../petstore_api/models/hunting_dog.py | 67 +- .../petstore_api/models/info.py | 66 +- .../models/inner_dict_with_property.py | 60 +- .../petstore_api/models/input_all_of.py | 74 +- .../petstore_api/models/int_or_string.py | 122 +- .../petstore_api/models/list_class.py | 60 +- .../models/map_of_array_of_model.py | 78 +- .../petstore_api/models/map_test.py | 68 +- ...perties_and_additional_properties_class.py | 76 +- .../petstore_api/models/model200_response.py | 61 +- .../petstore_api/models/model_api_response.py | 62 +- .../petstore_api/models/model_field.py | 60 +- .../petstore_api/models/model_return.py | 60 +- .../petstore_api/models/multi_arrays.py | 77 +- .../petstore_api/models/name.py | 69 +- .../petstore_api/models/nullable_class.py | 141 +- .../petstore_api/models/nullable_property.py | 68 +- .../petstore_api/models/number_only.py | 60 +- .../object_to_test_additional_properties.py | 60 +- .../models/object_with_deprecated_fields.py | 68 +- .../petstore_api/models/order.py | 70 +- .../petstore_api/models/outer_composite.py | 62 +- .../models/outer_object_with_enum_property.py | 68 +- .../petstore_api/models/parent.py | 74 +- .../models/parent_with_optional_dict.py | 74 +- .../python-aiohttp/petstore_api/models/pet.py | 82 +- .../python-aiohttp/petstore_api/models/pig.py | 117 +- .../petstore_api/models/pony_sizes.py | 60 +- .../petstore_api/models/poop_cleaning.py | 74 +- .../petstore_api/models/primitive_string.py | 61 +- .../petstore_api/models/property_map.py | 74 +- .../models/property_name_collision.py | 62 +- .../petstore_api/models/read_only_first.py | 65 +- .../models/second_circular_all_of_ref.py | 70 +- .../petstore_api/models/second_ref.py | 66 +- .../models/self_reference_model.py | 66 +- .../petstore_api/models/special_model_name.py | 60 +- .../petstore_api/models/special_name.py | 72 +- .../python-aiohttp/petstore_api/models/tag.py | 61 +- .../petstore_api/models/task.py | 66 +- .../petstore_api/models/task_activity.py | 127 +- ..._error_responses_with_model400_response.py | 60 +- ..._error_responses_with_model404_response.py | 60 +- ..._freeform_additional_properties_request.py | 74 +- .../models/test_model_with_enum_default.py | 69 +- ...t_for_multipart_requests_request_marker.py | 60 +- .../petstore_api/models/tiger.py | 60 +- ...t_with_additional_model_list_properties.py | 78 +- ..._with_additional_string_list_properties.py | 60 +- ...th_additional_properties_request_object.py | 60 +- .../petstore_api/models/user.py | 67 +- .../petstore_api/models/with_nested_one_of.py | 67 +- .../docs/AdditionalPropertiesAnyType.md | 8 +- .../docs/AdditionalPropertiesClass.md | 8 +- .../docs/AdditionalPropertiesObject.md | 8 +- ...AdditionalPropertiesWithDescriptionOnly.md | 8 +- .../python-httpx/docs/AllOfSuperModel.md | 8 +- .../python-httpx/docs/AllOfWithSingleRef.md | 8 +- .../petstore/python-httpx/docs/Animal.md | 8 +- .../petstore/python-httpx/docs/AnyOfColor.md | 8 +- .../petstore/python-httpx/docs/AnyOfPig.md | 8 +- .../python-httpx/docs/ArrayOfArrayOfModel.md | 8 +- .../docs/ArrayOfArrayOfNumberOnly.md | 8 +- .../python-httpx/docs/ArrayOfNumberOnly.md | 8 +- .../petstore/python-httpx/docs/ArrayTest.md | 8 +- .../python-httpx/docs/BaseDiscriminator.md | 8 +- .../petstore/python-httpx/docs/BasquePig.md | 8 +- .../petstore/python-httpx/docs/Bathing.md | 8 +- .../python-httpx/docs/Capitalization.md | 8 +- .../client/petstore/python-httpx/docs/Cat.md | 8 +- .../petstore/python-httpx/docs/Category.md | 8 +- .../python-httpx/docs/CircularAllOfRef.md | 8 +- .../docs/CircularReferenceModel.md | 8 +- .../petstore/python-httpx/docs/ClassModel.md | 8 +- .../petstore/python-httpx/docs/Client.md | 8 +- .../petstore/python-httpx/docs/Color.md | 8 +- .../petstore/python-httpx/docs/Creature.md | 8 +- .../python-httpx/docs/CreatureInfo.md | 8 +- .../petstore/python-httpx/docs/DanishPig.md | 8 +- .../python-httpx/docs/DeprecatedObject.md | 8 +- .../docs/DiscriminatorAllOfSub.md | 8 +- .../docs/DiscriminatorAllOfSuper.md | 8 +- .../client/petstore/python-httpx/docs/Dog.md | 8 +- .../petstore/python-httpx/docs/DummyModel.md | 8 +- .../petstore/python-httpx/docs/EnumArrays.md | 8 +- .../docs/EnumRefWithDefaultValue.md | 8 +- .../petstore/python-httpx/docs/EnumTest.md | 8 +- .../petstore/python-httpx/docs/Feeding.md | 8 +- .../client/petstore/python-httpx/docs/File.md | 8 +- .../python-httpx/docs/FileSchemaTestClass.md | 8 +- .../petstore/python-httpx/docs/FirstRef.md | 8 +- .../client/petstore/python-httpx/docs/Foo.md | 8 +- .../docs/FooGetDefaultResponse.md | 8 +- .../petstore/python-httpx/docs/FormatTest.md | 8 +- .../python-httpx/docs/HasOnlyReadOnly.md | 8 +- .../python-httpx/docs/HealthCheckResult.md | 8 +- .../petstore/python-httpx/docs/HuntingDog.md | 8 +- .../client/petstore/python-httpx/docs/Info.md | 8 +- .../docs/InnerDictWithProperty.md | 8 +- .../petstore/python-httpx/docs/InputAllOf.md | 8 +- .../petstore/python-httpx/docs/IntOrString.md | 8 +- .../petstore/python-httpx/docs/ListClass.md | 8 +- .../python-httpx/docs/MapOfArrayOfModel.md | 8 +- .../petstore/python-httpx/docs/MapTest.md | 8 +- ...dPropertiesAndAdditionalPropertiesClass.md | 8 +- .../python-httpx/docs/Model200Response.md | 8 +- .../python-httpx/docs/ModelApiResponse.md | 8 +- .../petstore/python-httpx/docs/ModelField.md | 8 +- .../petstore/python-httpx/docs/ModelReturn.md | 8 +- .../petstore/python-httpx/docs/MultiArrays.md | 8 +- .../client/petstore/python-httpx/docs/Name.md | 8 +- .../python-httpx/docs/NullableClass.md | 8 +- .../python-httpx/docs/NullableProperty.md | 8 +- .../petstore/python-httpx/docs/NumberOnly.md | 8 +- .../docs/ObjectToTestAdditionalProperties.md | 8 +- .../docs/ObjectWithDeprecatedFields.md | 8 +- .../petstore/python-httpx/docs/Order.md | 8 +- .../python-httpx/docs/OuterComposite.md | 8 +- .../docs/OuterObjectWithEnumProperty.md | 8 +- .../petstore/python-httpx/docs/Parent.md | 8 +- .../docs/ParentWithOptionalDict.md | 8 +- .../client/petstore/python-httpx/docs/Pet.md | 8 +- .../client/petstore/python-httpx/docs/Pig.md | 8 +- .../petstore/python-httpx/docs/PonySizes.md | 8 +- .../python-httpx/docs/PoopCleaning.md | 8 +- .../python-httpx/docs/PrimitiveString.md | 8 +- .../petstore/python-httpx/docs/PropertyMap.md | 8 +- .../docs/PropertyNameCollision.md | 8 +- .../python-httpx/docs/ReadOnlyFirst.md | 8 +- .../docs/SecondCircularAllOfRef.md | 8 +- .../petstore/python-httpx/docs/SecondRef.md | 8 +- .../python-httpx/docs/SelfReferenceModel.md | 8 +- .../python-httpx/docs/SpecialModelName.md | 8 +- .../petstore/python-httpx/docs/SpecialName.md | 8 +- .../client/petstore/python-httpx/docs/Tag.md | 8 +- .../client/petstore/python-httpx/docs/Task.md | 8 +- .../python-httpx/docs/TaskActivity.md | 8 +- .../TestErrorResponsesWithModel400Response.md | 8 +- .../TestErrorResponsesWithModel404Response.md | 8 +- ...lineFreeformAdditionalPropertiesRequest.md | 8 +- .../docs/TestModelWithEnumDefault.md | 8 +- ...ObjectForMultipartRequestsRequestMarker.md | 8 +- .../petstore/python-httpx/docs/Tiger.md | 8 +- ...edDictWithAdditionalModelListProperties.md | 8 +- ...dDictWithAdditionalStringListProperties.md | 8 +- ...leWithAdditionalPropertiesRequestObject.md | 8 +- .../client/petstore/python-httpx/docs/User.md | 8 +- .../python-httpx/docs/WithNestedOneOf.md | 8 +- .../models/additional_properties_any_type.py | 74 +- .../models/additional_properties_class.py | 61 +- .../models/additional_properties_object.py | 74 +- ...tional_properties_with_description_only.py | 74 +- .../petstore_api/models/all_of_super_model.py | 60 +- .../models/all_of_with_single_ref.py | 61 +- .../petstore_api/models/animal.py | 60 +- .../petstore_api/models/any_of_color.py | 139 +- .../petstore_api/models/any_of_pig.py | 116 +- .../models/array_of_array_of_model.py | 74 +- .../models/array_of_array_of_number_only.py | 60 +- .../models/array_of_number_only.py | 60 +- .../petstore_api/models/array_test.py | 77 +- .../petstore_api/models/base_discriminator.py | 60 +- .../petstore_api/models/basque_pig.py | 61 +- .../petstore_api/models/bathing.py | 74 +- .../petstore_api/models/capitalization.py | 65 +- .../python-httpx/petstore_api/models/cat.py | 62 +- .../petstore_api/models/category.py | 61 +- .../models/circular_all_of_ref.py | 70 +- .../models/circular_reference_model.py | 66 +- .../petstore_api/models/class_model.py | 60 +- .../petstore_api/models/client.py | 60 +- .../python-httpx/petstore_api/models/color.py | 147 +- .../petstore_api/models/creature.py | 63 +- .../petstore_api/models/creature_info.py | 60 +- .../petstore_api/models/danish_pig.py | 61 +- .../petstore_api/models/deprecated_object.py | 60 +- .../models/discriminator_all_of_sub.py | 60 +- .../models/discriminator_all_of_super.py | 58 +- .../python-httpx/petstore_api/models/dog.py | 62 +- .../petstore_api/models/dummy_model.py | 66 +- .../petstore_api/models/enum_arrays.py | 71 +- .../models/enum_ref_with_default_value.py | 60 +- .../petstore_api/models/enum_test.py | 116 +- .../petstore_api/models/feeding.py | 74 +- .../python-httpx/petstore_api/models/file.py | 60 +- .../models/file_schema_test_class.py | 73 +- .../petstore_api/models/first_ref.py | 66 +- .../python-httpx/petstore_api/models/foo.py | 60 +- .../models/foo_get_default_response.py | 65 +- .../petstore_api/models/format_test.py | 76 +- .../petstore_api/models/has_only_read_only.py | 67 +- .../models/health_check_result.py | 67 +- .../petstore_api/models/hunting_dog.py | 67 +- .../python-httpx/petstore_api/models/info.py | 66 +- .../models/inner_dict_with_property.py | 60 +- .../petstore_api/models/input_all_of.py | 74 +- .../petstore_api/models/int_or_string.py | 122 +- .../petstore_api/models/list_class.py | 60 +- .../models/map_of_array_of_model.py | 78 +- .../petstore_api/models/map_test.py | 68 +- ...perties_and_additional_properties_class.py | 76 +- .../petstore_api/models/model200_response.py | 61 +- .../petstore_api/models/model_api_response.py | 62 +- .../petstore_api/models/model_field.py | 60 +- .../petstore_api/models/model_return.py | 60 +- .../petstore_api/models/multi_arrays.py | 77 +- .../python-httpx/petstore_api/models/name.py | 69 +- .../petstore_api/models/nullable_class.py | 141 +- .../petstore_api/models/nullable_property.py | 68 +- .../petstore_api/models/number_only.py | 60 +- .../object_to_test_additional_properties.py | 60 +- .../models/object_with_deprecated_fields.py | 68 +- .../python-httpx/petstore_api/models/order.py | 70 +- .../petstore_api/models/outer_composite.py | 62 +- .../models/outer_object_with_enum_property.py | 68 +- .../petstore_api/models/parent.py | 74 +- .../models/parent_with_optional_dict.py | 74 +- .../python-httpx/petstore_api/models/pet.py | 82 +- .../python-httpx/petstore_api/models/pig.py | 117 +- .../petstore_api/models/pony_sizes.py | 60 +- .../petstore_api/models/poop_cleaning.py | 74 +- .../petstore_api/models/primitive_string.py | 61 +- .../petstore_api/models/property_map.py | 74 +- .../models/property_name_collision.py | 62 +- .../petstore_api/models/read_only_first.py | 65 +- .../models/second_circular_all_of_ref.py | 70 +- .../petstore_api/models/second_ref.py | 66 +- .../models/self_reference_model.py | 66 +- .../petstore_api/models/special_model_name.py | 60 +- .../petstore_api/models/special_name.py | 72 +- .../python-httpx/petstore_api/models/tag.py | 61 +- .../python-httpx/petstore_api/models/task.py | 66 +- .../petstore_api/models/task_activity.py | 127 +- ..._error_responses_with_model400_response.py | 60 +- ..._error_responses_with_model404_response.py | 60 +- ..._freeform_additional_properties_request.py | 74 +- .../models/test_model_with_enum_default.py | 69 +- ...t_for_multipart_requests_request_marker.py | 60 +- .../python-httpx/petstore_api/models/tiger.py | 60 +- ...t_with_additional_model_list_properties.py | 78 +- ..._with_additional_string_list_properties.py | 60 +- ...th_additional_properties_request_object.py | 60 +- .../python-httpx/petstore_api/models/user.py | 67 +- .../petstore_api/models/with_nested_one_of.py | 67 +- .../docs/AdditionalPropertiesAnyType.md | 8 +- .../docs/AdditionalPropertiesClass.md | 8 +- .../docs/AdditionalPropertiesObject.md | 8 +- ...AdditionalPropertiesWithDescriptionOnly.md | 8 +- .../docs/AllOfSuperModel.md | 8 +- .../docs/AllOfWithSingleRef.md | 8 +- .../python-lazyImports/docs/Animal.md | 8 +- .../python-lazyImports/docs/AnyOfColor.md | 8 +- .../python-lazyImports/docs/AnyOfPig.md | 8 +- .../docs/ArrayOfArrayOfModel.md | 8 +- .../docs/ArrayOfArrayOfNumberOnly.md | 8 +- .../docs/ArrayOfNumberOnly.md | 8 +- .../python-lazyImports/docs/ArrayTest.md | 8 +- .../docs/BaseDiscriminator.md | 8 +- .../python-lazyImports/docs/BasquePig.md | 8 +- .../python-lazyImports/docs/Bathing.md | 8 +- .../python-lazyImports/docs/Capitalization.md | 8 +- .../petstore/python-lazyImports/docs/Cat.md | 8 +- .../python-lazyImports/docs/Category.md | 8 +- .../docs/CircularAllOfRef.md | 8 +- .../docs/CircularReferenceModel.md | 8 +- .../python-lazyImports/docs/ClassModel.md | 8 +- .../python-lazyImports/docs/Client.md | 8 +- .../petstore/python-lazyImports/docs/Color.md | 8 +- .../python-lazyImports/docs/Creature.md | 8 +- .../python-lazyImports/docs/CreatureInfo.md | 8 +- .../python-lazyImports/docs/DanishPig.md | 8 +- .../docs/DeprecatedObject.md | 8 +- .../docs/DiscriminatorAllOfSub.md | 8 +- .../docs/DiscriminatorAllOfSuper.md | 8 +- .../petstore/python-lazyImports/docs/Dog.md | 8 +- .../python-lazyImports/docs/DummyModel.md | 8 +- .../python-lazyImports/docs/EnumArrays.md | 8 +- .../docs/EnumRefWithDefaultValue.md | 8 +- .../python-lazyImports/docs/EnumTest.md | 8 +- .../python-lazyImports/docs/Feeding.md | 8 +- .../petstore/python-lazyImports/docs/File.md | 8 +- .../docs/FileSchemaTestClass.md | 8 +- .../python-lazyImports/docs/FirstRef.md | 8 +- .../petstore/python-lazyImports/docs/Foo.md | 8 +- .../docs/FooGetDefaultResponse.md | 8 +- .../python-lazyImports/docs/FormatTest.md | 8 +- .../docs/HasOnlyReadOnly.md | 8 +- .../docs/HealthCheckResult.md | 8 +- .../python-lazyImports/docs/HuntingDog.md | 8 +- .../petstore/python-lazyImports/docs/Info.md | 8 +- .../docs/InnerDictWithProperty.md | 8 +- .../python-lazyImports/docs/InputAllOf.md | 8 +- .../python-lazyImports/docs/IntOrString.md | 8 +- .../python-lazyImports/docs/ListClass.md | 8 +- .../docs/MapOfArrayOfModel.md | 8 +- .../python-lazyImports/docs/MapTest.md | 8 +- ...dPropertiesAndAdditionalPropertiesClass.md | 8 +- .../docs/Model200Response.md | 8 +- .../docs/ModelApiResponse.md | 8 +- .../python-lazyImports/docs/ModelField.md | 8 +- .../python-lazyImports/docs/ModelReturn.md | 8 +- .../python-lazyImports/docs/MultiArrays.md | 8 +- .../petstore/python-lazyImports/docs/Name.md | 8 +- .../python-lazyImports/docs/NullableClass.md | 8 +- .../docs/NullableProperty.md | 8 +- .../python-lazyImports/docs/NumberOnly.md | 8 +- .../docs/ObjectToTestAdditionalProperties.md | 8 +- .../docs/ObjectWithDeprecatedFields.md | 8 +- .../docs/OneOfEnumString.md | 8 +- .../petstore/python-lazyImports/docs/Order.md | 8 +- .../python-lazyImports/docs/OuterComposite.md | 8 +- .../docs/OuterObjectWithEnumProperty.md | 8 +- .../python-lazyImports/docs/Parent.md | 8 +- .../docs/ParentWithOptionalDict.md | 8 +- .../petstore/python-lazyImports/docs/Pet.md | 8 +- .../petstore/python-lazyImports/docs/Pig.md | 8 +- .../python-lazyImports/docs/PonySizes.md | 8 +- .../python-lazyImports/docs/PoopCleaning.md | 8 +- .../docs/PrimitiveString.md | 8 +- .../python-lazyImports/docs/PropertyMap.md | 8 +- .../docs/PropertyNameCollision.md | 8 +- .../python-lazyImports/docs/ReadOnlyFirst.md | 8 +- .../docs/SecondCircularAllOfRef.md | 8 +- .../python-lazyImports/docs/SecondRef.md | 8 +- .../docs/SelfReferenceModel.md | 8 +- .../docs/SpecialModelName.md | 8 +- .../python-lazyImports/docs/SpecialName.md | 8 +- .../petstore/python-lazyImports/docs/Tag.md | 8 +- .../petstore/python-lazyImports/docs/Task.md | 8 +- .../python-lazyImports/docs/TaskActivity.md | 8 +- .../TestErrorResponsesWithModel400Response.md | 8 +- .../TestErrorResponsesWithModel404Response.md | 8 +- ...lineFreeformAdditionalPropertiesRequest.md | 8 +- .../docs/TestModelWithEnumDefault.md | 8 +- ...ObjectForMultipartRequestsRequestMarker.md | 8 +- .../petstore/python-lazyImports/docs/Tiger.md | 8 +- ...edDictWithAdditionalModelListProperties.md | 8 +- ...dDictWithAdditionalStringListProperties.md | 8 +- ...leWithAdditionalPropertiesRequestObject.md | 8 +- .../petstore/python-lazyImports/docs/User.md | 8 +- .../docs/WithNestedOneOf.md | 8 +- .../models/additional_properties_any_type.py | 74 +- .../models/additional_properties_class.py | 75 +- .../models/additional_properties_object.py | 74 +- ...tional_properties_with_description_only.py | 74 +- .../petstore_api/models/all_of_super_model.py | 74 +- .../models/all_of_with_single_ref.py | 75 +- .../petstore_api/models/animal.py | 69 +- .../petstore_api/models/any_of_color.py | 139 +- .../petstore_api/models/any_of_pig.py | 116 +- .../models/array_of_array_of_model.py | 86 +- .../models/array_of_array_of_number_only.py | 74 +- .../models/array_of_number_only.py | 74 +- .../petstore_api/models/array_test.py | 89 +- .../petstore_api/models/base_discriminator.py | 69 +- .../petstore_api/models/basque_pig.py | 75 +- .../petstore_api/models/bathing.py | 88 +- .../petstore_api/models/capitalization.py | 79 +- .../petstore_api/models/cat.py | 76 +- .../petstore_api/models/category.py | 75 +- .../models/circular_all_of_ref.py | 82 +- .../models/circular_reference_model.py | 78 +- .../petstore_api/models/class_model.py | 74 +- .../petstore_api/models/client.py | 74 +- .../petstore_api/models/color.py | 147 +- .../petstore_api/models/creature.py | 70 +- .../petstore_api/models/creature_info.py | 74 +- .../petstore_api/models/danish_pig.py | 75 +- .../petstore_api/models/deprecated_object.py | 74 +- .../models/discriminator_all_of_sub.py | 74 +- .../models/discriminator_all_of_super.py | 67 +- .../petstore_api/models/dog.py | 76 +- .../petstore_api/models/dummy_model.py | 78 +- .../petstore_api/models/enum_arrays.py | 85 +- .../models/enum_ref_with_default_value.py | 74 +- .../petstore_api/models/enum_test.py | 128 +- .../petstore_api/models/feeding.py | 88 +- .../petstore_api/models/file.py | 74 +- .../models/file_schema_test_class.py | 85 +- .../petstore_api/models/first_ref.py | 78 +- .../petstore_api/models/foo.py | 74 +- .../models/foo_get_default_response.py | 77 +- .../petstore_api/models/format_test.py | 90 +- .../petstore_api/models/has_only_read_only.py | 79 +- .../models/health_check_result.py | 79 +- .../petstore_api/models/hunting_dog.py | 79 +- .../petstore_api/models/info.py | 78 +- .../models/inner_dict_with_property.py | 74 +- .../petstore_api/models/input_all_of.py | 86 +- .../petstore_api/models/int_or_string.py | 122 +- .../petstore_api/models/list_class.py | 74 +- .../models/map_of_array_of_model.py | 90 +- .../petstore_api/models/map_test.py | 82 +- ...perties_and_additional_properties_class.py | 88 +- .../petstore_api/models/model200_response.py | 75 +- .../petstore_api/models/model_api_response.py | 76 +- .../petstore_api/models/model_field.py | 74 +- .../petstore_api/models/model_return.py | 74 +- .../petstore_api/models/multi_arrays.py | 89 +- .../petstore_api/models/name.py | 81 +- .../petstore_api/models/nullable_class.py | 141 +- .../petstore_api/models/nullable_property.py | 80 +- .../petstore_api/models/number_only.py | 74 +- .../object_to_test_additional_properties.py | 74 +- .../models/object_with_deprecated_fields.py | 80 +- .../petstore_api/models/one_of_enum_string.py | 114 +- .../petstore_api/models/order.py | 84 +- .../petstore_api/models/outer_composite.py | 76 +- .../models/outer_object_with_enum_property.py | 80 +- .../petstore_api/models/parent.py | 86 +- .../models/parent_with_optional_dict.py | 86 +- .../petstore_api/models/pet.py | 94 +- .../petstore_api/models/pig.py | 132 +- .../petstore_api/models/pony_sizes.py | 74 +- .../petstore_api/models/poop_cleaning.py | 88 +- .../petstore_api/models/primitive_string.py | 75 +- .../petstore_api/models/property_map.py | 86 +- .../models/property_name_collision.py | 76 +- .../petstore_api/models/read_only_first.py | 77 +- .../models/second_circular_all_of_ref.py | 82 +- .../petstore_api/models/second_ref.py | 78 +- .../models/self_reference_model.py | 78 +- .../petstore_api/models/special_model_name.py | 74 +- .../petstore_api/models/special_name.py | 84 +- .../petstore_api/models/tag.py | 75 +- .../petstore_api/models/task.py | 78 +- .../petstore_api/models/task_activity.py | 127 +- ..._error_responses_with_model400_response.py | 74 +- ..._error_responses_with_model404_response.py | 74 +- ..._freeform_additional_properties_request.py | 74 +- .../models/test_model_with_enum_default.py | 83 +- ...t_for_multipart_requests_request_marker.py | 74 +- .../petstore_api/models/tiger.py | 74 +- ...t_with_additional_model_list_properties.py | 90 +- ..._with_additional_string_list_properties.py | 74 +- ...th_additional_properties_request_object.py | 74 +- .../petstore_api/models/user.py | 81 +- .../petstore_api/models/with_nested_one_of.py | 82 +- .../docs/AdditionalPropertiesAnyType.md | 8 +- .../python/docs/AdditionalPropertiesClass.md | 8 +- .../python/docs/AdditionalPropertiesObject.md | 8 +- ...AdditionalPropertiesWithDescriptionOnly.md | 8 +- .../petstore/python/docs/AllOfSuperModel.md | 8 +- .../python/docs/AllOfWithSingleRef.md | 8 +- .../client/petstore/python/docs/Animal.md | 8 +- .../client/petstore/python/docs/AnyOfColor.md | 8 +- .../client/petstore/python/docs/AnyOfPig.md | 8 +- .../python/docs/ArrayOfArrayOfModel.md | 8 +- .../python/docs/ArrayOfArrayOfNumberOnly.md | 8 +- .../petstore/python/docs/ArrayOfNumberOnly.md | 8 +- .../client/petstore/python/docs/ArrayTest.md | 8 +- .../petstore/python/docs/BaseDiscriminator.md | 8 +- .../client/petstore/python/docs/BasquePig.md | 8 +- .../client/petstore/python/docs/Bathing.md | 8 +- .../petstore/python/docs/Capitalization.md | 8 +- .../client/petstore/python/docs/Cat.md | 8 +- .../client/petstore/python/docs/Category.md | 8 +- .../petstore/python/docs/CircularAllOfRef.md | 8 +- .../python/docs/CircularReferenceModel.md | 8 +- .../client/petstore/python/docs/ClassModel.md | 8 +- .../client/petstore/python/docs/Client.md | 8 +- .../client/petstore/python/docs/Color.md | 8 +- .../client/petstore/python/docs/Creature.md | 8 +- .../petstore/python/docs/CreatureInfo.md | 8 +- .../client/petstore/python/docs/DanishPig.md | 8 +- .../petstore/python/docs/DeprecatedObject.md | 8 +- .../python/docs/DiscriminatorAllOfSub.md | 8 +- .../python/docs/DiscriminatorAllOfSuper.md | 8 +- .../client/petstore/python/docs/Dog.md | 8 +- .../client/petstore/python/docs/DummyModel.md | 8 +- .../client/petstore/python/docs/EnumArrays.md | 8 +- .../python/docs/EnumRefWithDefaultValue.md | 8 +- .../client/petstore/python/docs/EnumTest.md | 8 +- .../client/petstore/python/docs/Feeding.md | 8 +- .../client/petstore/python/docs/File.md | 8 +- .../python/docs/FileSchemaTestClass.md | 8 +- .../client/petstore/python/docs/FirstRef.md | 8 +- .../client/petstore/python/docs/Foo.md | 8 +- .../python/docs/FooGetDefaultResponse.md | 8 +- .../client/petstore/python/docs/FormatTest.md | 8 +- .../petstore/python/docs/HasOnlyReadOnly.md | 8 +- .../petstore/python/docs/HealthCheckResult.md | 8 +- .../client/petstore/python/docs/HuntingDog.md | 8 +- .../client/petstore/python/docs/Info.md | 8 +- .../python/docs/InnerDictWithProperty.md | 8 +- .../client/petstore/python/docs/InputAllOf.md | 8 +- .../petstore/python/docs/IntOrString.md | 8 +- .../client/petstore/python/docs/ListClass.md | 8 +- .../petstore/python/docs/MapOfArrayOfModel.md | 8 +- .../client/petstore/python/docs/MapTest.md | 8 +- ...dPropertiesAndAdditionalPropertiesClass.md | 8 +- .../petstore/python/docs/Model200Response.md | 8 +- .../petstore/python/docs/ModelApiResponse.md | 8 +- .../client/petstore/python/docs/ModelField.md | 8 +- .../petstore/python/docs/ModelReturn.md | 8 +- .../petstore/python/docs/MultiArrays.md | 8 +- .../client/petstore/python/docs/Name.md | 8 +- .../petstore/python/docs/NullableClass.md | 8 +- .../petstore/python/docs/NullableProperty.md | 8 +- .../client/petstore/python/docs/NumberOnly.md | 8 +- .../docs/ObjectToTestAdditionalProperties.md | 8 +- .../python/docs/ObjectWithDeprecatedFields.md | 8 +- .../petstore/python/docs/OneOfEnumString.md | 8 +- .../client/petstore/python/docs/Order.md | 8 +- .../petstore/python/docs/OuterComposite.md | 8 +- .../docs/OuterObjectWithEnumProperty.md | 8 +- .../client/petstore/python/docs/Parent.md | 8 +- .../python/docs/ParentWithOptionalDict.md | 8 +- .../client/petstore/python/docs/Pet.md | 8 +- .../client/petstore/python/docs/Pig.md | 8 +- .../client/petstore/python/docs/PonySizes.md | 8 +- .../petstore/python/docs/PoopCleaning.md | 8 +- .../petstore/python/docs/PrimitiveString.md | 8 +- .../petstore/python/docs/PropertyMap.md | 8 +- .../python/docs/PropertyNameCollision.md | 8 +- .../petstore/python/docs/ReadOnlyFirst.md | 8 +- .../python/docs/SecondCircularAllOfRef.md | 8 +- .../client/petstore/python/docs/SecondRef.md | 8 +- .../python/docs/SelfReferenceModel.md | 8 +- .../petstore/python/docs/SpecialModelName.md | 8 +- .../petstore/python/docs/SpecialName.md | 8 +- .../client/petstore/python/docs/Tag.md | 8 +- .../client/petstore/python/docs/Task.md | 8 +- .../petstore/python/docs/TaskActivity.md | 8 +- .../TestErrorResponsesWithModel400Response.md | 8 +- .../TestErrorResponsesWithModel404Response.md | 8 +- ...lineFreeformAdditionalPropertiesRequest.md | 8 +- .../python/docs/TestModelWithEnumDefault.md | 8 +- ...ObjectForMultipartRequestsRequestMarker.md | 8 +- .../client/petstore/python/docs/Tiger.md | 8 +- ...edDictWithAdditionalModelListProperties.md | 8 +- ...dDictWithAdditionalStringListProperties.md | 8 +- ...leWithAdditionalPropertiesRequestObject.md | 8 +- .../client/petstore/python/docs/User.md | 8 +- .../petstore/python/docs/WithNestedOneOf.md | 8 +- .../models/additional_properties_any_type.py | 74 +- .../models/additional_properties_class.py | 75 +- .../models/additional_properties_object.py | 74 +- ...tional_properties_with_description_only.py | 74 +- .../petstore_api/models/all_of_super_model.py | 74 +- .../models/all_of_with_single_ref.py | 75 +- .../python/petstore_api/models/animal.py | 69 +- .../petstore_api/models/any_of_color.py | 139 +- .../python/petstore_api/models/any_of_pig.py | 116 +- .../models/array_of_array_of_model.py | 86 +- .../models/array_of_array_of_number_only.py | 74 +- .../models/array_of_number_only.py | 74 +- .../python/petstore_api/models/array_test.py | 89 +- .../petstore_api/models/base_discriminator.py | 69 +- .../python/petstore_api/models/basque_pig.py | 75 +- .../python/petstore_api/models/bathing.py | 88 +- .../petstore_api/models/capitalization.py | 79 +- .../python/petstore_api/models/cat.py | 76 +- .../python/petstore_api/models/category.py | 75 +- .../models/circular_all_of_ref.py | 82 +- .../models/circular_reference_model.py | 78 +- .../python/petstore_api/models/class_model.py | 74 +- .../python/petstore_api/models/client.py | 74 +- .../python/petstore_api/models/color.py | 147 +- .../python/petstore_api/models/creature.py | 70 +- .../petstore_api/models/creature_info.py | 74 +- .../python/petstore_api/models/danish_pig.py | 75 +- .../petstore_api/models/deprecated_object.py | 74 +- .../models/discriminator_all_of_sub.py | 74 +- .../models/discriminator_all_of_super.py | 67 +- .../python/petstore_api/models/dog.py | 76 +- .../python/petstore_api/models/dummy_model.py | 78 +- .../python/petstore_api/models/enum_arrays.py | 85 +- .../models/enum_ref_with_default_value.py | 74 +- .../python/petstore_api/models/enum_test.py | 128 +- .../python/petstore_api/models/feeding.py | 88 +- .../python/petstore_api/models/file.py | 74 +- .../models/file_schema_test_class.py | 85 +- .../python/petstore_api/models/first_ref.py | 78 +- .../python/petstore_api/models/foo.py | 74 +- .../models/foo_get_default_response.py | 77 +- .../python/petstore_api/models/format_test.py | 90 +- .../petstore_api/models/has_only_read_only.py | 79 +- .../models/health_check_result.py | 79 +- .../python/petstore_api/models/hunting_dog.py | 79 +- .../python/petstore_api/models/info.py | 78 +- .../models/inner_dict_with_property.py | 74 +- .../petstore_api/models/input_all_of.py | 86 +- .../petstore_api/models/int_or_string.py | 122 +- .../python/petstore_api/models/list_class.py | 74 +- .../models/map_of_array_of_model.py | 90 +- .../python/petstore_api/models/map_test.py | 82 +- ...perties_and_additional_properties_class.py | 88 +- .../petstore_api/models/model200_response.py | 75 +- .../petstore_api/models/model_api_response.py | 76 +- .../python/petstore_api/models/model_field.py | 74 +- .../petstore_api/models/model_return.py | 74 +- .../petstore_api/models/multi_arrays.py | 89 +- .../python/petstore_api/models/name.py | 81 +- .../petstore_api/models/nullable_class.py | 141 +- .../petstore_api/models/nullable_property.py | 80 +- .../python/petstore_api/models/number_only.py | 74 +- .../object_to_test_additional_properties.py | 74 +- .../models/object_with_deprecated_fields.py | 80 +- .../petstore_api/models/one_of_enum_string.py | 114 +- .../python/petstore_api/models/order.py | 84 +- .../petstore_api/models/outer_composite.py | 76 +- .../models/outer_object_with_enum_property.py | 80 +- .../python/petstore_api/models/parent.py | 86 +- .../models/parent_with_optional_dict.py | 86 +- .../python/petstore_api/models/pet.py | 94 +- .../python/petstore_api/models/pig.py | 132 +- .../python/petstore_api/models/pony_sizes.py | 74 +- .../petstore_api/models/poop_cleaning.py | 88 +- .../petstore_api/models/primitive_string.py | 75 +- .../petstore_api/models/property_map.py | 86 +- .../models/property_name_collision.py | 76 +- .../petstore_api/models/read_only_first.py | 77 +- .../models/second_circular_all_of_ref.py | 82 +- .../python/petstore_api/models/second_ref.py | 78 +- .../models/self_reference_model.py | 78 +- .../petstore_api/models/special_model_name.py | 74 +- .../petstore_api/models/special_name.py | 84 +- .../python/petstore_api/models/tag.py | 75 +- .../python/petstore_api/models/task.py | 78 +- .../petstore_api/models/task_activity.py | 127 +- ..._error_responses_with_model400_response.py | 74 +- ..._error_responses_with_model404_response.py | 74 +- ..._freeform_additional_properties_request.py | 74 +- .../models/test_model_with_enum_default.py | 83 +- ...t_for_multipart_requests_request_marker.py | 74 +- .../python/petstore_api/models/tiger.py | 74 +- ...t_with_additional_model_list_properties.py | 90 +- ..._with_additional_string_list_properties.py | 74 +- ...th_additional_properties_request_object.py | 74 +- .../python/petstore_api/models/user.py | 81 +- .../petstore_api/models/with_nested_one_of.py | 82 +- .../GeneratePathParamsValidationFilter.cs | 107 ++ .../GeneratePathParamsValidationFilter.cs | 107 ++ .../Filters/BasePathFilter.cs | 60 + .../GeneratePathParamsValidationFilter.cs | 107 ++ .../GeneratePathParamsValidationFilter.cs | 107 ++ .../GeneratePathParamsValidationFilter.cs | 107 ++ .../wwwroot/openapi-original.json | 1203 +++++++++++++++++ .../GeneratePathParamsValidationFilter.cs | 107 ++ .../GeneratePathParamsValidationFilter.cs | 107 ++ .../GeneratePathParamsValidationFilter.cs | 107 ++ .../wwwroot/openapi-original.json | 1203 +++++++++++++++++ .../wwwroot/openapi-original.json | 1203 +++++++++++++++++ .../GeneratePathParamsValidationFilter.cs | 107 ++ .../GeneratePathParamsValidationFilter.cs | 107 ++ .../wwwroot/openapi-original.json | 1021 ++++++++++++++ .../server/petstore/cpp-oatpp/model/Order.hpp | 59 + .../server/petstore/cpp-oatpp/model/Tag.hpp | 51 + .../cpp-pistache-everything/model/Order.cpp | 251 ++++ .../api/StoreApi.cpp | 103 ++ .../petstore/cpp-pistache/model/Category.cpp | 135 ++ 876 files changed, 17020 insertions(+), 24692 deletions(-) diff --git a/docs/generators/crystal.md b/docs/generators/crystal.md index ba481b67e4da..ea2b3cc400db 100644 --- a/docs/generators/crystal.md +++ b/docs/generators/crystal.md @@ -94,7 +94,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • if
  • in
  • include
  • -
  • instance
  • +
  • instance_sizeof
  • is_a?
  • lib
  • macro
  • @@ -102,9 +102,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • next
  • nil
  • nil?
  • +
  • object_id
  • of
  • out
  • pointerof
  • +
  • previous_def
  • private
  • protected
  • require
  • diff --git a/docs/generators/groovy.md b/docs/generators/groovy.md index e2f1314c4bb1..d5cdff849435 100644 --- a/docs/generators/groovy.md +++ b/docs/generators/groovy.md @@ -30,10 +30,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-dubbo.md b/docs/generators/java-dubbo.md index fa64f3d35955..2ea83de8db02 100644 --- a/docs/generators/java-dubbo.md +++ b/docs/generators/java-dubbo.md @@ -34,10 +34,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |configPackage|configuration package for generated code| |org.openapitools.configuration| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-helidon-client.md b/docs/generators/java-helidon-client.md index 5f309c81ce6b..06f803388070 100644 --- a/docs/generators/java-helidon-client.md +++ b/docs/generators/java-helidon-client.md @@ -33,6 +33,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl |configKey|Config key in @RegisterRestClient. Default to none.| |null| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| diff --git a/docs/generators/java-helidon-server.md b/docs/generators/java-helidon-server.md index b4d8db132743..f456ed9ce064 100644 --- a/docs/generators/java-helidon-server.md +++ b/docs/generators/java-helidon-server.md @@ -32,6 +32,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| diff --git a/docs/generators/java-inflector.md b/docs/generators/java-inflector.md index 3adfffad38df..7054f33501ac 100644 --- a/docs/generators/java-inflector.md +++ b/docs/generators/java-inflector.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-micronaut-client.md b/docs/generators/java-micronaut-client.md index 37a2d8907ee1..645025f315d8 100644 --- a/docs/generators/java-micronaut-client.md +++ b/docs/generators/java-micronaut-client.md @@ -41,10 +41,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |dateFormat|Specify the format pattern of date as a string| |null| |dateLibrary|Option. Date library to use|
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| |datetimeFormat|Specify the format pattern of date-time as a string| |null| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-micronaut-server.md b/docs/generators/java-micronaut-server.md index 4a21268afbd5..73fb9dd977ad 100644 --- a/docs/generators/java-micronaut-server.md +++ b/docs/generators/java-micronaut-server.md @@ -36,10 +36,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |dateFormat|Specify the format pattern of date as a string| |null| |dateLibrary|Option. Date library to use|
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| |datetimeFormat|Specify the format pattern of date-time as a string| |null| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-microprofile.md b/docs/generators/java-microprofile.md index 9e02b37145ef..7f87f275d343 100644 --- a/docs/generators/java-microprofile.md +++ b/docs/generators/java-microprofile.md @@ -37,10 +37,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |configKeyFromClassName|If true, set tag as key in @RegisterRestClient. Default to false. Only `microprofile` supports this option.| |null| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-msf4j.md b/docs/generators/java-msf4j.md index 7251308c1440..25842d8df871 100644 --- a/docs/generators/java-msf4j.md +++ b/docs/generators/java-msf4j.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-pkmst.md b/docs/generators/java-pkmst.md index e2299587c5f2..fc5e849f837b 100644 --- a/docs/generators/java-pkmst.md +++ b/docs/generators/java-pkmst.md @@ -33,10 +33,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-play-framework.md b/docs/generators/java-play-framework.md index c5f80ab75d16..f30134f8ec8c 100644 --- a/docs/generators/java-play-framework.md +++ b/docs/generators/java-play-framework.md @@ -35,10 +35,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |controllerOnly|Whether to generate only API interface stubs without the server files.| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-undertow-server.md b/docs/generators/java-undertow-server.md index c258e9aa5df4..1356bc33f589 100644 --- a/docs/generators/java-undertow-server.md +++ b/docs/generators/java-undertow-server.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-vertx-web.md b/docs/generators/java-vertx-web.md index 473c40d1af7d..e4156c53a887 100644 --- a/docs/generators/java-vertx-web.md +++ b/docs/generators/java-vertx-web.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-vertx.md b/docs/generators/java-vertx.md index dd2722079b63..5a8d19f0ee4f 100644 --- a/docs/generators/java-vertx.md +++ b/docs/generators/java-vertx.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java-wiremock.md b/docs/generators/java-wiremock.md index 39b0a40d6edf..e6f238f31ffc 100644 --- a/docs/generators/java-wiremock.md +++ b/docs/generators/java-wiremock.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/java.md b/docs/generators/java.md index b98c5386e4e5..85da80e56a9e 100644 --- a/docs/generators/java.md +++ b/docs/generators/java.md @@ -37,10 +37,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |configKeyFromClassName|If true, set tag as key in @RegisterRestClient. Default to false. Only `microprofile` supports this option.| |null| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |java8| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md index 02f6b177827e..eb7f94c2993d 100644 --- a/docs/generators/jaxrs-cxf-cdi.md +++ b/docs/generators/jaxrs-cxf-cdi.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md index e735d8f0ef4b..bed567bf4f05 100644 --- a/docs/generators/jaxrs-cxf-client.md +++ b/docs/generators/jaxrs-cxf-client.md @@ -33,10 +33,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md index aeb82d2dce55..00971949946b 100644 --- a/docs/generators/jaxrs-cxf-extended.md +++ b/docs/generators/jaxrs-cxf-extended.md @@ -34,10 +34,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md index b9b120e2f8d9..7325c0b5965b 100644 --- a/docs/generators/jaxrs-cxf.md +++ b/docs/generators/jaxrs-cxf.md @@ -34,10 +34,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-jersey.md b/docs/generators/jaxrs-jersey.md index a5d3e9a3c51a..59186e03fa91 100644 --- a/docs/generators/jaxrs-jersey.md +++ b/docs/generators/jaxrs-jersey.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-resteasy-eap.md b/docs/generators/jaxrs-resteasy-eap.md index 85a3ea082300..ce5dd75fe065 100644 --- a/docs/generators/jaxrs-resteasy-eap.md +++ b/docs/generators/jaxrs-resteasy-eap.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-resteasy.md b/docs/generators/jaxrs-resteasy.md index c03831051659..f451f945b804 100644 --- a/docs/generators/jaxrs-resteasy.md +++ b/docs/generators/jaxrs-resteasy.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md index 03c2d043bf78..a36ac50aef17 100644 --- a/docs/generators/jaxrs-spec.md +++ b/docs/generators/jaxrs-spec.md @@ -32,10 +32,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl |camelCaseDollarSign|Fix camelCase when starting with $ sign. when true : $Value when false : $value| |false| |containerDefaultToNull|Set containers (array, set, map) default to null| |false| |dateLibrary|Option. Date library to use|
    **joda**
    Joda (for legacy app only)
    **legacy**
    Legacy java.util.Date
    **java8-localdatetime**
    Java 8 using LocalDateTime (for legacy app only)
    **java8**
    Java 8 native JSR310 (preferred for jdk 1.8+)
    |legacy| +|defaultToEmptyContainer|Initialize containers (array/set/map) to empty containers instead of null by default. Usage: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#default-values| |null| |developerEmail|developer email in generated pom.xml| |team@openapitools.org| |developerName|developer name in generated pom.xml| |OpenAPI-Generator Contributors| |developerOrganization|developer organization in generated pom.xml| |OpenAPITools.org| |developerOrganizationUrl|developer organization URL in generated pom.xml| |http://openapitools.org| +|disableDiscriminatorJsonIgnoreProperties|Ignore discriminator field type for Jackson serialization| |false| |disableHtmlEscaping|Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)| |false| |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.
    |true| |discriminatorCaseSensitive|Whether the discriminator value lookup should be case-sensitive or not. This option only works for Java API client| |true| diff --git a/docs/generators/kotlin-server.md b/docs/generators/kotlin-server.md index 733e819e6ce3..86859ea27401 100644 --- a/docs/generators/kotlin-server.md +++ b/docs/generators/kotlin-server.md @@ -30,6 +30,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |featureHSTS|Avoid sending content if client already has same content, by checking ETag or LastModified properties.| |true| |featureMetrics|Enables metrics feature.| |true| |featureResources|Generates routes in a typed way, for both: constructing URLs and reading the parameters.| |true| +|fixJacksonJsonTypeInfoInheritance|When true (default), ensures Jackson polymorphism works correctly by: (1) always setting visible=true on @JsonTypeInfo, and (2) adding the discriminator property to child models with appropriate default values. When false, visible is only set to true if all children already define the discriminator property.| |true| |groupId|Generated artifact package's organization (i.e. maven groupId).| |org.openapitools| |interfaceOnly|Whether to generate only API interface stubs without the server files. This option is currently supported only when using jaxrs-spec library.| |false| |library|library template (sub-template)|
    **ktor**
    ktor framework
    **ktor2**
    ktor (2.x) framework
    **jaxrs-spec**
    JAX-RS spec only
    **javalin5**
    Javalin 5
    **javalin6**
    Javalin 6
    |ktor| @@ -262,11 +263,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ---- | --------- | ---------- | |Simple|✓|OAS2,OAS3 |Composite|✓|OAS2,OAS3 -|Polymorphism|✗|OAS2,OAS3 +|Polymorphism|✓|OAS2,OAS3 |Union|✗|OAS3 -|allOf|✗|OAS2,OAS3 +|allOf|✓|OAS2,OAS3 |anyOf|✗|OAS3 -|oneOf|✗|OAS3 +|oneOf|✓|OAS3 |not|✗|OAS3 ### Security Feature diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md index 4eb0030c1734..e03dfd102929 100644 --- a/docs/generators/kotlin-spring.md +++ b/docs/generators/kotlin-spring.md @@ -44,6 +44,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl |parcelizeModels|toggle "@Parcelize" for generated models| |null| |reactive|use coroutines for reactive behavior| |false| |requestMappingMode|Where to generate the class level @RequestMapping annotation.|
    **api_interface**
    Generate the @RequestMapping annotation on the generated Api Interface.
    **controller**
    Generate the @RequestMapping annotation on the generated Api Controller Implementation.
    **none**
    Do not add a class level @RequestMapping annotation.
    |controller| +|schemaImplements|A map of single interface or a list of interfaces per schema name that should be implemented (serves similar purpose as `x-kotlin-implements`, but is fully decoupled from the api spec). Example: yaml `schemaImplements: {Pet: com.some.pack.WithId, Category: [com.some.pack.CategoryInterface], Dog: [com.some.pack.Canine, com.some.pack.OtherInterface]}` implements interfaces in schemas `Pet` (interface `com.some.pack.WithId`), `Category` (interface `com.some.pack.CategoryInterface`), `Dog`(interfaces `com.some.pack.Canine`, `com.some.pack.OtherInterface`)| |empty map| +|schemaImplementsFields|A map of single field or a list of fields per schema name that should be prepended with `override` (serves similar purpose as `x-kotlin-implements-fields`, but is fully decoupled from the api spec). Example: yaml `schemaImplementsFields: {Pet: id, Category: [name, id], Dog: [bark, breed]}` marks fields to be prepended with `override` in schemas `Pet` (field `id`), `Category` (fields `name`, `id`) and `Dog` (fields `bark`, `breed`)| |empty map| |serializableModel|boolean - toggle "implements Serializable" for generated models| |null| |serverPort|configuration the port in which the sever is to run on| |8080| |serviceImplementation|generate stub service implementations that extends service interfaces. If this is set to true service interfaces will also be generated| |false| @@ -57,9 +59,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useFeignClientUrl|Whether to generate Feign client with url parameter.| |true| |useFlowForArrayReturnType|Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.| |true| |useResponseEntity|Whether (when false) to return actual type (e.g. List<Fruit>) and handle non-happy path responses via exceptions flow or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>). If disabled, method are annotated using a @ResponseStatus annotation, which has the status of the first response declared in the Api definition| |true| -|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot 3.x. (Use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false| +|useSpringBoot3|Generate code and provide dependencies for use with Spring Boot ≥ 3 (use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false| |useSwaggerUI|Open the OpenApi specification in swagger-ui. Will also import and configure needed dependencies| |true| |useTags|Whether to use tags for creating interface and controller class names| |false| +|xKotlinImplementsFieldsSkip|A list of fields per schema name that should NOT be created with `override` keyword despite their presence in vendor extension `x-kotlin-implements-fields` for the schema. Example: yaml `xKotlinImplementsFieldsSkip: Pet: [photoUrls]` skips `override` for `photoUrls` in schema `Pet`| |empty map| +|xKotlinImplementsSkip|A list of fully qualified interfaces that should NOT be implemented despite their presence in vendor extension `x-kotlin-implements`. Example: yaml `xKotlinImplementsSkip: [com.some.pack.WithPhotoUrls]` skips implementing the interface in any schema| |empty list| ## SUPPORTED VENDOR EXTENSIONS diff --git a/docs/generators/protobuf-schema.md b/docs/generators/protobuf-schema.md index fc8616619336..e01683760038 100644 --- a/docs/generators/protobuf-schema.md +++ b/docs/generators/protobuf-schema.md @@ -22,6 +22,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |aggregateModelsName|Aggregated model filename. If set, all generated models will be combined into this single file.| |null| |customOptionsApi|Custom options for the api files.| |null| |customOptionsModel|Custom options for the model files.| |null| +|extractEnumsToSeparateFiles|Extract enums to separate protobuf files and import them in models| |false| |numberedFieldNumberList|Field numbers in order.| |false| |startEnumsWithUnspecified|Introduces "UNSPECIFIED" as the first element of enumerations.| |false| |supportMultipleResponses|Support multiple responses| |true| diff --git a/docs/generators/python-fastapi.md b/docs/generators/python-fastapi.md index 5a87a2fcee28..4e706a4c1a52 100644 --- a/docs/generators/python-fastapi.md +++ b/docs/generators/python-fastapi.md @@ -10,7 +10,7 @@ title: Documentation for the python-fastapi Generator | generator stability | BETA | | | generator type | SERVER | | | generator language | Python | | -| generator language version | 3.7 | | +| generator language version | 3.10 | | | generator default templating engine | mustache | | | helpTxt | Generates a Python FastAPI server (beta). Models are defined with the pydantic library | | diff --git a/docs/generators/swift5.md b/docs/generators/swift5.md index 9d565bf5993f..68376d466186 100644 --- a/docs/generators/swift5.md +++ b/docs/generators/swift5.md @@ -7,7 +7,7 @@ title: Documentation for the swift5 Generator | Property | Value | Notes | | -------- | ----- | ----- | | generator name | swift5 | pass this to the generate command after -g | -| generator stability | STABLE | | +| generator stability | DEPRECATED | | | generator type | CLIENT | | | generator language | Swift | | | generator default templating engine | mustache | | diff --git a/docs/generators/typescript-angular.md b/docs/generators/typescript-angular.md index 7d7c88af9979..f9f96573a4af 100644 --- a/docs/generators/typescript-angular.md +++ b/docs/generators/typescript-angular.md @@ -11,7 +11,7 @@ title: Documentation for the typescript-angular Generator | generator type | CLIENT | | | generator language | Typescript | | | generator default templating engine | mustache | | -| helpTxt | Generates a TypeScript Angular (9.x - 20.x) client library. | | +| helpTxt | Generates a TypeScript Angular (9.x - 21.x) client library. | | ## CONFIG OPTIONS These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details. @@ -34,7 +34,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original| |modelSuffix|The suffix of the generated model.| |null| |ngPackagrVersion|The version of ng-packagr compatible with Angular (see ngVersion option).| |null| -|ngVersion|The version of Angular. (At least 9.0.0)| |20.0.0| +|ngVersion|The version of Angular. (At least 9.0.0)| |21.0.0| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| |npmRepository|Use this property to set an url your private npmRepo in the package.json| |null| |npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0| diff --git a/docs/generators/typescript-axios.md b/docs/generators/typescript-axios.md index 269c2b09587e..62f77eca1828 100644 --- a/docs/generators/typescript-axios.md +++ b/docs/generators/typescript-axios.md @@ -20,7 +20,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl | ------ | ----------- | ------ | ------- | |allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false| |apiPackage|package for generated api classes| |null| -|axiosVersion|Use this property to override the axios version in package.json| |^1.6.1| +|axiosVersion|Use this property to override the axios version in package.json| |^1.13.5| |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.
    |true| |ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true| |enumNameSuffix|Suffix that will be appended to all enum names.| |Enum| diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 5634f424a966..8616f926108d 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -42,6 +42,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |supportsES6|Generate code that conforms to ES6.| |false| +|typescriptMajorVersion|Specify the major version of TypeScript to use in the client code. Default is 5.| |5| |useErasableSyntax|Use erasable syntax for the generated code. This is a temporary feature and will be removed in the future.| |false| |useInversify|Enable this to generate decorators and service identifiers for the InversifyJS inversion of control container. If you set 'deno' as 'platform', the generator will process this value as 'disable'.| |false| |useObjectParameters|Use aggregate parameter objects as function arguments for api operations instead of passing each parameter as a separate function argument.| |false| diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Bird.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Bird.md index e61d8458c978..b288e5d280c3 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Bird.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Bird.md @@ -16,14 +16,14 @@ from openapi_client.models.bird import Bird # TODO update the JSON string below json = "{}" # create an instance of Bird from a JSON string -bird_instance = Bird.from_json(json) +bird_instance = Bird.model_validate_json(json) # print the JSON string representation of the object -print(Bird.to_json()) +print(bird_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -bird_dict = bird_instance.to_dict() +bird_dict = bird_instance.model_dump(by_alias=True) # create an instance of Bird from a dict -bird_from_dict = Bird.from_dict(bird_dict) +bird_from_dict = Bird.model_validate(bird_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Category.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Category.md index 9a807466f62a..ca4428075dc4 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Category.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Category.md @@ -16,14 +16,14 @@ from openapi_client.models.category import Category # TODO update the JSON string below json = "{}" # create an instance of Category from a JSON string -category_instance = Category.from_json(json) +category_instance = Category.model_validate_json(json) # print the JSON string representation of the object -print(Category.to_json()) +print(category_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -category_dict = category_instance.to_dict() +category_dict = category_instance.model_dump(by_alias=True) # create an instance of Category from a dict -category_from_dict = Category.from_dict(category_dict) +category_from_dict = Category.model_validate(category_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DataQuery.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DataQuery.md index 7ea37bfd23e1..662bd88a9bec 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DataQuery.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DataQuery.md @@ -17,14 +17,14 @@ from openapi_client.models.data_query import DataQuery # TODO update the JSON string below json = "{}" # create an instance of DataQuery from a JSON string -data_query_instance = DataQuery.from_json(json) +data_query_instance = DataQuery.model_validate_json(json) # print the JSON string representation of the object -print(DataQuery.to_json()) +print(data_query_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -data_query_dict = data_query_instance.to_dict() +data_query_dict = data_query_instance.model_dump(by_alias=True) # create an instance of DataQuery from a dict -data_query_from_dict = DataQuery.from_dict(data_query_dict) +data_query_from_dict = DataQuery.model_validate(data_query_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md index 7c1668c0d6c6..a2a4d3703f37 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/DefaultValue.md @@ -23,14 +23,14 @@ from openapi_client.models.default_value import DefaultValue # TODO update the JSON string below json = "{}" # create an instance of DefaultValue from a JSON string -default_value_instance = DefaultValue.from_json(json) +default_value_instance = DefaultValue.model_validate_json(json) # print the JSON string representation of the object -print(DefaultValue.to_json()) +print(default_value_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -default_value_dict = default_value_instance.to_dict() +default_value_dict = default_value_instance.model_dump(by_alias=True) # create an instance of DefaultValue from a dict -default_value_from_dict = DefaultValue.from_dict(default_value_dict) +default_value_from_dict = DefaultValue.model_validate(default_value_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/NumberPropertiesOnly.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/NumberPropertiesOnly.md index 1f9cb5a1f634..f1883e65d024 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/NumberPropertiesOnly.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/NumberPropertiesOnly.md @@ -17,14 +17,14 @@ from openapi_client.models.number_properties_only import NumberPropertiesOnly # TODO update the JSON string below json = "{}" # create an instance of NumberPropertiesOnly from a JSON string -number_properties_only_instance = NumberPropertiesOnly.from_json(json) +number_properties_only_instance = NumberPropertiesOnly.model_validate_json(json) # print the JSON string representation of the object -print(NumberPropertiesOnly.to_json()) +print(number_properties_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -number_properties_only_dict = number_properties_only_instance.to_dict() +number_properties_only_dict = number_properties_only_instance.model_dump(by_alias=True) # create an instance of NumberPropertiesOnly from a dict -number_properties_only_from_dict = NumberPropertiesOnly.from_dict(number_properties_only_dict) +number_properties_only_from_dict = NumberPropertiesOnly.model_validate(number_properties_only_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Pet.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Pet.md index 99b4bf3ab010..026ef653d443 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Pet.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Pet.md @@ -20,14 +20,14 @@ from openapi_client.models.pet import Pet # TODO update the JSON string below json = "{}" # create an instance of Pet from a JSON string -pet_instance = Pet.from_json(json) +pet_instance = Pet.model_validate_json(json) # print the JSON string representation of the object -print(Pet.to_json()) +print(pet_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pet_dict = pet_instance.to_dict() +pet_dict = pet_instance.model_dump(by_alias=True) # create an instance of Pet from a dict -pet_from_dict = Pet.from_dict(pet_dict) +pet_from_dict = Pet.model_validate(pet_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Query.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Query.md index d39693eb5b93..c72cdf145b32 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Query.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Query.md @@ -16,14 +16,14 @@ from openapi_client.models.query import Query # TODO update the JSON string below json = "{}" # create an instance of Query from a JSON string -query_instance = Query.from_json(json) +query_instance = Query.model_validate_json(json) # print the JSON string representation of the object -print(Query.to_json()) +print(query_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -query_dict = query_instance.to_dict() +query_dict = query_instance.model_dump(by_alias=True) # create an instance of Query from a dict -query_from_dict = Query.from_dict(query_dict) +query_from_dict = Query.model_validate(query_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Tag.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Tag.md index 21314992cf43..3abb8b678e2c 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Tag.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/Tag.md @@ -16,14 +16,14 @@ from openapi_client.models.tag import Tag # TODO update the JSON string below json = "{}" # create an instance of Tag from a JSON string -tag_instance = Tag.from_json(json) +tag_instance = Tag.model_validate_json(json) # print the JSON string representation of the object -print(Tag.to_json()) +print(tag_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tag_dict = tag_instance.to_dict() +tag_dict = tag_instance.model_dump(by_alias=True) # create an instance of Tag from a dict -tag_from_dict = Tag.from_dict(tag_dict) +tag_from_dict = Tag.model_validate(tag_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestFormObjectMultipartRequestMarker.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestFormObjectMultipartRequestMarker.md index bf4046eb4648..0c5dee4f8f69 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestFormObjectMultipartRequestMarker.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestFormObjectMultipartRequestMarker.md @@ -15,14 +15,14 @@ from openapi_client.models.test_form_object_multipart_request_marker import Test # TODO update the JSON string below json = "{}" # create an instance of TestFormObjectMultipartRequestMarker from a JSON string -test_form_object_multipart_request_marker_instance = TestFormObjectMultipartRequestMarker.from_json(json) +test_form_object_multipart_request_marker_instance = TestFormObjectMultipartRequestMarker.model_validate_json(json) # print the JSON string representation of the object -print(TestFormObjectMultipartRequestMarker.to_json()) +print(test_form_object_multipart_request_marker_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_form_object_multipart_request_marker_dict = test_form_object_multipart_request_marker_instance.to_dict() +test_form_object_multipart_request_marker_dict = test_form_object_multipart_request_marker_instance.model_dump(by_alias=True) # create an instance of TestFormObjectMultipartRequestMarker from a dict -test_form_object_multipart_request_marker_from_dict = TestFormObjectMultipartRequestMarker.from_dict(test_form_object_multipart_request_marker_dict) +test_form_object_multipart_request_marker_from_dict = TestFormObjectMultipartRequestMarker.model_validate(test_form_object_multipart_request_marker_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md index 96c36ca12e0f..9cda4fca20c8 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md @@ -18,14 +18,14 @@ from openapi_client.models.test_query_style_deep_object_explode_true_object_all_ # TODO update the JSON string below json = "{}" # create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string -test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.from_json(json) +test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.model_validate_json(json) # print the JSON string representation of the object -print(TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.to_json()) +print(test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_dict = test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance.to_dict() +test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_dict = test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance.model_dump(by_alias=True) # create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict -test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_from_dict = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.from_dict(test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_dict) +test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_from_dict = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.model_validate(test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md index 846a0941a09c..6af94f3aed1a 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md @@ -15,14 +15,14 @@ from openapi_client.models.test_query_style_form_explode_true_array_string_query # TODO update the JSON string below json = "{}" # create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string -test_query_style_form_explode_true_array_string_query_object_parameter_instance = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.from_json(json) +test_query_style_form_explode_true_array_string_query_object_parameter_instance = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate_json(json) # print the JSON string representation of the object -print(TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.to_json()) +print(test_query_style_form_explode_true_array_string_query_object_parameter_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_query_style_form_explode_true_array_string_query_object_parameter_dict = test_query_style_form_explode_true_array_string_query_object_parameter_instance.to_dict() +test_query_style_form_explode_true_array_string_query_object_parameter_dict = test_query_style_form_explode_true_array_string_query_object_parameter_instance.model_dump(by_alias=True) # create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict -test_query_style_form_explode_true_array_string_query_object_parameter_from_dict = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.from_dict(test_query_style_form_explode_true_array_string_query_object_parameter_dict) +test_query_style_form_explode_true_array_string_query_object_parameter_from_dict = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate(test_query_style_form_explode_true_array_string_query_object_parameter_dict) ``` [[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/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py index 9bb24b9e6d80..3d968f7ccb2a 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Bird(BaseModel): """ @@ -38,58 +39,27 @@ class Bird(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Bird from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Bird from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in Bird) in the input: " + _key) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "color": obj.get("color") - }) - return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py index c8e9bb709fd1..6eff61d49cd5 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Category(BaseModel): """ @@ -38,58 +39,27 @@ class Category(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Category from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Category from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in Category) in the input: " + _key) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py index 255a5ab7f422..b1c63f49eb43 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py @@ -23,7 +23,8 @@ from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.query import Query from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DataQuery(Query): """ @@ -41,61 +42,27 @@ class DataQuery(Query): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DataQuery from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DataQuery from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in DataQuery) in the input: " + _key) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "outcomes": obj.get("outcomes"), - "suffix": obj.get("suffix"), - "text": obj.get("text"), - "date": obj.get("date") - }) - return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py index 8dceac31e3d5..10e69104c4e4 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py @@ -22,14 +22,18 @@ from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.string_enum_ref import StringEnumRef from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DefaultValue(BaseModel): """ to test the default value of properties """ # noqa: E501 array_string_enum_ref_default: Optional[List[StringEnumRef]] = None - array_string_enum_default: Optional[List[StrictStr]] = None + array_string_enum_default: Optional[List[Literal['success', 'failure', 'unclassified']]] = Field( + None, + description="array_string_enum_default of the DefaultValue" + ) array_string_default: Optional[List[StrictStr]] = None array_integer_default: Optional[List[StrictInt]] = None array_string: Optional[List[StrictStr]] = None @@ -56,79 +60,27 @@ def array_string_enum_default_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DefaultValue from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if array_string_nullable (nullable) is None - # and model_fields_set contains the field - if self.array_string_nullable is None and "array_string_nullable" in self.model_fields_set: - _dict['array_string_nullable'] = None - - # set to None if array_string_extension_nullable (nullable) is None - # and model_fields_set contains the field - if self.array_string_extension_nullable is None and "array_string_extension_nullable" in self.model_fields_set: - _dict['array_string_extension_nullable'] = None - - # set to None if string_nullable (nullable) is None - # and model_fields_set contains the field - if self.string_nullable is None and "string_nullable" in self.model_fields_set: - _dict['string_nullable'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DefaultValue from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in DefaultValue) in the input: " + _key) - - _obj = cls.model_validate({ - "array_string_enum_ref_default": obj.get("array_string_enum_ref_default"), - "array_string_enum_default": obj.get("array_string_enum_default"), - "array_string_default": obj.get("array_string_default"), - "array_integer_default": obj.get("array_integer_default"), - "array_string": obj.get("array_string"), - "array_string_nullable": obj.get("array_string_nullable"), - "array_string_extension_nullable": obj.get("array_string_extension_nullable"), - "string_nullable": obj.get("string_nullable") - }) - return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py index d089c9775ace..6f0dc9bac787 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py @@ -22,7 +22,8 @@ from typing import Any, ClassVar, Dict, List, Optional, Union from typing_extensions import Annotated from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NumberPropertiesOnly(BaseModel): """ @@ -40,59 +41,27 @@ class NumberPropertiesOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NumberPropertiesOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NumberPropertiesOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in NumberPropertiesOnly) in the input: " + _key) - - _obj = cls.model_validate({ - "number": obj.get("number"), - "float": obj.get("float"), - "double": obj.get("double") - }) - return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py index bfe90956d977..f266995ab4be 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py @@ -23,7 +23,8 @@ from openapi_client.models.category import Category from openapi_client.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Pet(BaseModel): """ @@ -34,7 +35,10 @@ class Pet(BaseModel): category: Optional[Category] = None photo_urls: List[StrictStr] = Field(alias="photoUrls") tags: Optional[List[Tag]] = None - status: Optional[StrictStr] = Field(default=None, description="pet status in the store") + status: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) __properties: ClassVar[List[str]] = ["id", "name", "category", "photoUrls", "tags", "status"] @field_validator('status') @@ -54,72 +58,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Pet from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of category - if self.category: - _dict['category'] = self.category.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Pet from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in Pet) in the input: " + _key) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name"), - "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, - "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "status": obj.get("status") - }) - return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py index 97199fb7fd95..cd07519afcee 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py @@ -21,14 +21,18 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Query(BaseModel): """ Query """ # noqa: E501 id: Optional[StrictInt] = Field(default=None, description="Query") - outcomes: Optional[List[StrictStr]] = None + outcomes: Optional[List[Literal['SUCCESS', 'FAILURE', 'SKIPPED']]] = Field( + None, + description="outcomes of the Query" + ) __properties: ClassVar[List[str]] = ["id", "outcomes"] @field_validator('outcomes') @@ -49,42 +53,27 @@ def outcomes_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Query from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Self]: - """Create an instance of Query from a dict""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py index 5ec177ca73ae..629143cb5037 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tag(BaseModel): """ @@ -38,58 +39,27 @@ class Tag(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tag from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tag from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in Tag) in the input: " + _key) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py index 9fab70ea178d..a0e8fa663e86 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestFormObjectMultipartRequestMarker(BaseModel): """ @@ -37,57 +38,27 @@ class TestFormObjectMultipartRequestMarker(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestFormObjectMultipartRequestMarker from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestFormObjectMultipartRequestMarker from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in TestFormObjectMultipartRequestMarker) in the input: " + _key) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 8cf292b6a90b..f1d93067251e 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel): """ @@ -40,60 +41,27 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter) in the input: " + _key) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "color": obj.get("color"), - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 726b427743ca..e0fe6d0f8e3d 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): """ @@ -37,57 +38,27 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - # raise errors for additional fields in the input - for _key in obj.keys(): - if _key not in cls.__properties: - raise ValueError("Error due to additional fields (not defined in TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter) in the input: " + _key) - - _obj = cls.model_validate({ - "values": obj.get("values") - }) - return _obj diff --git a/samples/client/echo_api/python/docs/Bird.md b/samples/client/echo_api/python/docs/Bird.md index e61d8458c978..b288e5d280c3 100644 --- a/samples/client/echo_api/python/docs/Bird.md +++ b/samples/client/echo_api/python/docs/Bird.md @@ -16,14 +16,14 @@ from openapi_client.models.bird import Bird # TODO update the JSON string below json = "{}" # create an instance of Bird from a JSON string -bird_instance = Bird.from_json(json) +bird_instance = Bird.model_validate_json(json) # print the JSON string representation of the object -print(Bird.to_json()) +print(bird_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -bird_dict = bird_instance.to_dict() +bird_dict = bird_instance.model_dump(by_alias=True) # create an instance of Bird from a dict -bird_from_dict = Bird.from_dict(bird_dict) +bird_from_dict = Bird.model_validate(bird_dict) ``` [[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/echo_api/python/docs/Category.md b/samples/client/echo_api/python/docs/Category.md index 9a807466f62a..ca4428075dc4 100644 --- a/samples/client/echo_api/python/docs/Category.md +++ b/samples/client/echo_api/python/docs/Category.md @@ -16,14 +16,14 @@ from openapi_client.models.category import Category # TODO update the JSON string below json = "{}" # create an instance of Category from a JSON string -category_instance = Category.from_json(json) +category_instance = Category.model_validate_json(json) # print the JSON string representation of the object -print(Category.to_json()) +print(category_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -category_dict = category_instance.to_dict() +category_dict = category_instance.model_dump(by_alias=True) # create an instance of Category from a dict -category_from_dict = Category.from_dict(category_dict) +category_from_dict = Category.model_validate(category_dict) ``` [[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/echo_api/python/docs/DataQuery.md b/samples/client/echo_api/python/docs/DataQuery.md index 7ea37bfd23e1..662bd88a9bec 100644 --- a/samples/client/echo_api/python/docs/DataQuery.md +++ b/samples/client/echo_api/python/docs/DataQuery.md @@ -17,14 +17,14 @@ from openapi_client.models.data_query import DataQuery # TODO update the JSON string below json = "{}" # create an instance of DataQuery from a JSON string -data_query_instance = DataQuery.from_json(json) +data_query_instance = DataQuery.model_validate_json(json) # print the JSON string representation of the object -print(DataQuery.to_json()) +print(data_query_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -data_query_dict = data_query_instance.to_dict() +data_query_dict = data_query_instance.model_dump(by_alias=True) # create an instance of DataQuery from a dict -data_query_from_dict = DataQuery.from_dict(data_query_dict) +data_query_from_dict = DataQuery.model_validate(data_query_dict) ``` [[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/echo_api/python/docs/DefaultValue.md b/samples/client/echo_api/python/docs/DefaultValue.md index 7c1668c0d6c6..a2a4d3703f37 100644 --- a/samples/client/echo_api/python/docs/DefaultValue.md +++ b/samples/client/echo_api/python/docs/DefaultValue.md @@ -23,14 +23,14 @@ from openapi_client.models.default_value import DefaultValue # TODO update the JSON string below json = "{}" # create an instance of DefaultValue from a JSON string -default_value_instance = DefaultValue.from_json(json) +default_value_instance = DefaultValue.model_validate_json(json) # print the JSON string representation of the object -print(DefaultValue.to_json()) +print(default_value_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -default_value_dict = default_value_instance.to_dict() +default_value_dict = default_value_instance.model_dump(by_alias=True) # create an instance of DefaultValue from a dict -default_value_from_dict = DefaultValue.from_dict(default_value_dict) +default_value_from_dict = DefaultValue.model_validate(default_value_dict) ``` [[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/echo_api/python/docs/NumberPropertiesOnly.md b/samples/client/echo_api/python/docs/NumberPropertiesOnly.md index 1f9cb5a1f634..f1883e65d024 100644 --- a/samples/client/echo_api/python/docs/NumberPropertiesOnly.md +++ b/samples/client/echo_api/python/docs/NumberPropertiesOnly.md @@ -17,14 +17,14 @@ from openapi_client.models.number_properties_only import NumberPropertiesOnly # TODO update the JSON string below json = "{}" # create an instance of NumberPropertiesOnly from a JSON string -number_properties_only_instance = NumberPropertiesOnly.from_json(json) +number_properties_only_instance = NumberPropertiesOnly.model_validate_json(json) # print the JSON string representation of the object -print(NumberPropertiesOnly.to_json()) +print(number_properties_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -number_properties_only_dict = number_properties_only_instance.to_dict() +number_properties_only_dict = number_properties_only_instance.model_dump(by_alias=True) # create an instance of NumberPropertiesOnly from a dict -number_properties_only_from_dict = NumberPropertiesOnly.from_dict(number_properties_only_dict) +number_properties_only_from_dict = NumberPropertiesOnly.model_validate(number_properties_only_dict) ``` [[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/echo_api/python/docs/Pet.md b/samples/client/echo_api/python/docs/Pet.md index 99b4bf3ab010..026ef653d443 100644 --- a/samples/client/echo_api/python/docs/Pet.md +++ b/samples/client/echo_api/python/docs/Pet.md @@ -20,14 +20,14 @@ from openapi_client.models.pet import Pet # TODO update the JSON string below json = "{}" # create an instance of Pet from a JSON string -pet_instance = Pet.from_json(json) +pet_instance = Pet.model_validate_json(json) # print the JSON string representation of the object -print(Pet.to_json()) +print(pet_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pet_dict = pet_instance.to_dict() +pet_dict = pet_instance.model_dump(by_alias=True) # create an instance of Pet from a dict -pet_from_dict = Pet.from_dict(pet_dict) +pet_from_dict = Pet.model_validate(pet_dict) ``` [[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/echo_api/python/docs/Query.md b/samples/client/echo_api/python/docs/Query.md index d39693eb5b93..c72cdf145b32 100644 --- a/samples/client/echo_api/python/docs/Query.md +++ b/samples/client/echo_api/python/docs/Query.md @@ -16,14 +16,14 @@ from openapi_client.models.query import Query # TODO update the JSON string below json = "{}" # create an instance of Query from a JSON string -query_instance = Query.from_json(json) +query_instance = Query.model_validate_json(json) # print the JSON string representation of the object -print(Query.to_json()) +print(query_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -query_dict = query_instance.to_dict() +query_dict = query_instance.model_dump(by_alias=True) # create an instance of Query from a dict -query_from_dict = Query.from_dict(query_dict) +query_from_dict = Query.model_validate(query_dict) ``` [[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/echo_api/python/docs/Tag.md b/samples/client/echo_api/python/docs/Tag.md index 21314992cf43..3abb8b678e2c 100644 --- a/samples/client/echo_api/python/docs/Tag.md +++ b/samples/client/echo_api/python/docs/Tag.md @@ -16,14 +16,14 @@ from openapi_client.models.tag import Tag # TODO update the JSON string below json = "{}" # create an instance of Tag from a JSON string -tag_instance = Tag.from_json(json) +tag_instance = Tag.model_validate_json(json) # print the JSON string representation of the object -print(Tag.to_json()) +print(tag_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tag_dict = tag_instance.to_dict() +tag_dict = tag_instance.model_dump(by_alias=True) # create an instance of Tag from a dict -tag_from_dict = Tag.from_dict(tag_dict) +tag_from_dict = Tag.model_validate(tag_dict) ``` [[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/echo_api/python/docs/TestFormObjectMultipartRequestMarker.md b/samples/client/echo_api/python/docs/TestFormObjectMultipartRequestMarker.md index bf4046eb4648..0c5dee4f8f69 100644 --- a/samples/client/echo_api/python/docs/TestFormObjectMultipartRequestMarker.md +++ b/samples/client/echo_api/python/docs/TestFormObjectMultipartRequestMarker.md @@ -15,14 +15,14 @@ from openapi_client.models.test_form_object_multipart_request_marker import Test # TODO update the JSON string below json = "{}" # create an instance of TestFormObjectMultipartRequestMarker from a JSON string -test_form_object_multipart_request_marker_instance = TestFormObjectMultipartRequestMarker.from_json(json) +test_form_object_multipart_request_marker_instance = TestFormObjectMultipartRequestMarker.model_validate_json(json) # print the JSON string representation of the object -print(TestFormObjectMultipartRequestMarker.to_json()) +print(test_form_object_multipart_request_marker_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_form_object_multipart_request_marker_dict = test_form_object_multipart_request_marker_instance.to_dict() +test_form_object_multipart_request_marker_dict = test_form_object_multipart_request_marker_instance.model_dump(by_alias=True) # create an instance of TestFormObjectMultipartRequestMarker from a dict -test_form_object_multipart_request_marker_from_dict = TestFormObjectMultipartRequestMarker.from_dict(test_form_object_multipart_request_marker_dict) +test_form_object_multipart_request_marker_from_dict = TestFormObjectMultipartRequestMarker.model_validate(test_form_object_multipart_request_marker_dict) ``` [[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/echo_api/python/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md b/samples/client/echo_api/python/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md index 96c36ca12e0f..9cda4fca20c8 100644 --- a/samples/client/echo_api/python/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md +++ b/samples/client/echo_api/python/docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md @@ -18,14 +18,14 @@ from openapi_client.models.test_query_style_deep_object_explode_true_object_all_ # TODO update the JSON string below json = "{}" # create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string -test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.from_json(json) +test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.model_validate_json(json) # print the JSON string representation of the object -print(TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.to_json()) +print(test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_dict = test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance.to_dict() +test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_dict = test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_instance.model_dump(by_alias=True) # create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict -test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_from_dict = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.from_dict(test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_dict) +test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_from_dict = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.model_validate(test_query_style_deep_object_explode_true_object_all_of_query_object_parameter_dict) ``` [[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/echo_api/python/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md b/samples/client/echo_api/python/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md index 846a0941a09c..6af94f3aed1a 100644 --- a/samples/client/echo_api/python/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md +++ b/samples/client/echo_api/python/docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md @@ -15,14 +15,14 @@ from openapi_client.models.test_query_style_form_explode_true_array_string_query # TODO update the JSON string below json = "{}" # create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string -test_query_style_form_explode_true_array_string_query_object_parameter_instance = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.from_json(json) +test_query_style_form_explode_true_array_string_query_object_parameter_instance = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate_json(json) # print the JSON string representation of the object -print(TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.to_json()) +print(test_query_style_form_explode_true_array_string_query_object_parameter_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_query_style_form_explode_true_array_string_query_object_parameter_dict = test_query_style_form_explode_true_array_string_query_object_parameter_instance.to_dict() +test_query_style_form_explode_true_array_string_query_object_parameter_dict = test_query_style_form_explode_true_array_string_query_object_parameter_instance.model_dump(by_alias=True) # create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict -test_query_style_form_explode_true_array_string_query_object_parameter_from_dict = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.from_dict(test_query_style_form_explode_true_array_string_query_object_parameter_dict) +test_query_style_form_explode_true_array_string_query_object_parameter_from_dict = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.model_validate(test_query_style_form_explode_true_array_string_query_object_parameter_dict) ``` [[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/echo_api/python/openapi_client/models/bird.py b/samples/client/echo_api/python/openapi_client/models/bird.py index 9f0dd625119d..3d968f7ccb2a 100644 --- a/samples/client/echo_api/python/openapi_client/models/bird.py +++ b/samples/client/echo_api/python/openapi_client/models/bird.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Bird(BaseModel): """ @@ -38,53 +39,27 @@ class Bird(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Bird from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Bird from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "color": obj.get("color") - }) - return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/category.py b/samples/client/echo_api/python/openapi_client/models/category.py index d81b92c0f6e3..6eff61d49cd5 100644 --- a/samples/client/echo_api/python/openapi_client/models/category.py +++ b/samples/client/echo_api/python/openapi_client/models/category.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Category(BaseModel): """ @@ -38,53 +39,27 @@ class Category(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Category from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Category from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/data_query.py b/samples/client/echo_api/python/openapi_client/models/data_query.py index dc9a58598e63..b1c63f49eb43 100644 --- a/samples/client/echo_api/python/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python/openapi_client/models/data_query.py @@ -23,7 +23,8 @@ from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.query import Query from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DataQuery(Query): """ @@ -41,56 +42,27 @@ class DataQuery(Query): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DataQuery from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DataQuery from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "outcomes": obj.get("outcomes"), - "suffix": obj.get("suffix"), - "text": obj.get("text"), - "date": obj.get("date") - }) - return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/default_value.py b/samples/client/echo_api/python/openapi_client/models/default_value.py index feee1843319f..10e69104c4e4 100644 --- a/samples/client/echo_api/python/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python/openapi_client/models/default_value.py @@ -22,14 +22,18 @@ from typing import Any, ClassVar, Dict, List, Optional from openapi_client.models.string_enum_ref import StringEnumRef from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DefaultValue(BaseModel): """ to test the default value of properties """ # noqa: E501 array_string_enum_ref_default: Optional[List[StringEnumRef]] = None - array_string_enum_default: Optional[List[StrictStr]] = None + array_string_enum_default: Optional[List[Literal['success', 'failure', 'unclassified']]] = Field( + None, + description="array_string_enum_default of the DefaultValue" + ) array_string_default: Optional[List[StrictStr]] = None array_integer_default: Optional[List[StrictInt]] = None array_string: Optional[List[StrictStr]] = None @@ -56,74 +60,27 @@ def array_string_enum_default_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DefaultValue from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if array_string_nullable (nullable) is None - # and model_fields_set contains the field - if self.array_string_nullable is None and "array_string_nullable" in self.model_fields_set: - _dict['array_string_nullable'] = None - - # set to None if array_string_extension_nullable (nullable) is None - # and model_fields_set contains the field - if self.array_string_extension_nullable is None and "array_string_extension_nullable" in self.model_fields_set: - _dict['array_string_extension_nullable'] = None - - # set to None if string_nullable (nullable) is None - # and model_fields_set contains the field - if self.string_nullable is None and "string_nullable" in self.model_fields_set: - _dict['string_nullable'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DefaultValue from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "array_string_enum_ref_default": obj.get("array_string_enum_ref_default"), - "array_string_enum_default": obj.get("array_string_enum_default"), - "array_string_default": obj.get("array_string_default"), - "array_integer_default": obj.get("array_integer_default"), - "array_string": obj.get("array_string"), - "array_string_nullable": obj.get("array_string_nullable"), - "array_string_extension_nullable": obj.get("array_string_extension_nullable"), - "string_nullable": obj.get("string_nullable") - }) - return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py index 08b3d5600ffa..6f0dc9bac787 100644 --- a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py @@ -22,7 +22,8 @@ from typing import Any, ClassVar, Dict, List, Optional, Union from typing_extensions import Annotated from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NumberPropertiesOnly(BaseModel): """ @@ -40,54 +41,27 @@ class NumberPropertiesOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NumberPropertiesOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NumberPropertiesOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "number": obj.get("number"), - "float": obj.get("float"), - "double": obj.get("double") - }) - return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/pet.py b/samples/client/echo_api/python/openapi_client/models/pet.py index 0a0ae74d1155..f266995ab4be 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -23,7 +23,8 @@ from openapi_client.models.category import Category from openapi_client.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Pet(BaseModel): """ @@ -34,7 +35,10 @@ class Pet(BaseModel): category: Optional[Category] = None photo_urls: List[StrictStr] = Field(alias="photoUrls") tags: Optional[List[Tag]] = None - status: Optional[StrictStr] = Field(default=None, description="pet status in the store") + status: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) __properties: ClassVar[List[str]] = ["id", "name", "category", "photoUrls", "tags", "status"] @field_validator('status') @@ -54,67 +58,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Pet from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of category - if self.category: - _dict['category'] = self.category.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Pet from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name"), - "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, - "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "status": obj.get("status") - }) - return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/query.py b/samples/client/echo_api/python/openapi_client/models/query.py index 97199fb7fd95..cd07519afcee 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -21,14 +21,18 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Query(BaseModel): """ Query """ # noqa: E501 id: Optional[StrictInt] = Field(default=None, description="Query") - outcomes: Optional[List[StrictStr]] = None + outcomes: Optional[List[Literal['SUCCESS', 'FAILURE', 'SKIPPED']]] = Field( + None, + description="outcomes of the Query" + ) __properties: ClassVar[List[str]] = ["id", "outcomes"] @field_validator('outcomes') @@ -49,42 +53,27 @@ def outcomes_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Query from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Self]: - """Create an instance of Query from a dict""" diff --git a/samples/client/echo_api/python/openapi_client/models/tag.py b/samples/client/echo_api/python/openapi_client/models/tag.py index feec4b3f31cc..629143cb5037 100644 --- a/samples/client/echo_api/python/openapi_client/models/tag.py +++ b/samples/client/echo_api/python/openapi_client/models/tag.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tag(BaseModel): """ @@ -38,53 +39,27 @@ class Tag(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tag from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tag from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py index 9f7747151bd5..a0e8fa663e86 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestFormObjectMultipartRequestMarker(BaseModel): """ @@ -37,52 +38,27 @@ class TestFormObjectMultipartRequestMarker(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestFormObjectMultipartRequestMarker from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestFormObjectMultipartRequestMarker from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 8ed0f58c990b..f1d93067251e 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel): """ @@ -40,55 +41,27 @@ class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseMod ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "color": obj.get("color"), - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index a9a7a5929f2e..e0fe6d0f8e3d 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): """ @@ -37,52 +38,27 @@ class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "values": obj.get("values") - }) - return _obj diff --git a/samples/client/others/c/bearerAuth/model/object.c b/samples/client/others/c/bearerAuth/model/object.c index e69de29bb2d1..ff293bcdac85 100644 --- a/samples/client/others/c/bearerAuth/model/object.c +++ b/samples/client/others/c/bearerAuth/model/object.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include "object.h" + +object_t *object_create() { + object_t *object = calloc(1, sizeof(object_t)); + + return object; +} + +void object_free(object_t *object) { + if (!object) { + return ; + } + + if (object->temporary) { + free(object->temporary); + object->temporary = NULL; + } + + free (object); +} + +cJSON *object_convertToJSON(object_t *object) { + if (!object) { + return NULL; + } + + if (!object->temporary) { + return cJSON_Parse("null"); + } + + return cJSON_Parse(object->temporary); +} + +object_t *object_parseFromJSON(cJSON *json){ + if (!json) { + goto end; + } + + object_t *object = object_create(); + if (!object) { + goto end; + } + object->temporary = cJSON_Print(json); + return object; + +end: + return NULL; +} diff --git a/samples/client/petstore/bash/docs/MapTest.md b/samples/client/petstore/bash/docs/MapTest.md index e69de29bb2d1..e4ed4a233829 100644 --- a/samples/client/petstore/bash/docs/MapTest.md +++ b/samples/client/petstore/bash/docs/MapTest.md @@ -0,0 +1,13 @@ +# MapTest + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**mapUnderscoremapUnderscoreofUnderscorestring** | **map[String, map[String, string]]** | | [optional] [default to null] +**mapUnderscoreofUnderscoreenumUnderscorestring** | **map[String, string]** | | [optional] [default to null] +**directUnderscoremap** | **map[String, boolean]** | | [optional] [default to null] +**indirectUnderscoremap** | **map[String, boolean]** | | [optional] [default to null] + +[[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/bash/docs/Name.md b/samples/client/petstore/bash/docs/Name.md index e69de29bb2d1..295812c7bb7e 100644 --- a/samples/client/petstore/bash/docs/Name.md +++ b/samples/client/petstore/bash/docs/Name.md @@ -0,0 +1,13 @@ +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **integer** | | [default to null] +**snakeUnderscorecase** | **integer** | | [optional] [readonly] [default to null] +**property** | **string** | | [optional] [default to null] +**123Number** | **integer** | | [optional] [readonly] [default to null] + +[[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/c-useJsonUnformatted/model/pet.c b/samples/client/petstore/c-useJsonUnformatted/model/pet.c index e69de29bb2d1..b561634cb529 100644 --- a/samples/client/petstore/c-useJsonUnformatted/model/pet.c +++ b/samples/client/petstore/c-useJsonUnformatted/model/pet.c @@ -0,0 +1,335 @@ +#include +#include +#include +#include "pet.h" + + +char* pet_status_ToString(openapi_petstore_pet_STATUS_e status) { + char* statusArray[] = { "NULL", "available", "pending", "sold" }; + return statusArray[status]; +} + +openapi_petstore_pet_STATUS_e pet_status_FromString(char* status){ + int stringToReturn = 0; + char *statusArray[] = { "NULL", "available", "pending", "sold" }; + size_t sizeofArray = sizeof(statusArray) / sizeof(statusArray[0]); + while(stringToReturn < sizeofArray) { + if(strcmp(status, statusArray[stringToReturn]) == 0) { + return stringToReturn; + } + stringToReturn++; + } + return 0; +} + +static pet_t *pet_create_internal( + long id, + category_t *category, + char *name, + list_t *photo_urls, + list_t *tags, + openapi_petstore_pet_STATUS_e status + ) { + pet_t *pet_local_var = malloc(sizeof(pet_t)); + if (!pet_local_var) { + return NULL; + } + pet_local_var->id = id; + pet_local_var->category = category; + pet_local_var->name = name; + pet_local_var->photo_urls = photo_urls; + pet_local_var->tags = tags; + pet_local_var->status = status; + + pet_local_var->_library_owned = 1; + return pet_local_var; +} + +__attribute__((deprecated)) pet_t *pet_create( + long id, + category_t *category, + char *name, + list_t *photo_urls, + list_t *tags, + openapi_petstore_pet_STATUS_e status + ) { + return pet_create_internal ( + id, + category, + name, + photo_urls, + tags, + status + ); +} + +void pet_free(pet_t *pet) { + if(NULL == pet){ + return ; + } + if(pet->_library_owned != 1){ + fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "pet_free"); + return ; + } + listEntry_t *listEntry; + if (pet->category) { + category_free(pet->category); + pet->category = NULL; + } + if (pet->name) { + free(pet->name); + pet->name = NULL; + } + if (pet->photo_urls) { + list_ForEach(listEntry, pet->photo_urls) { + free(listEntry->data); + } + list_freeList(pet->photo_urls); + pet->photo_urls = NULL; + } + if (pet->tags) { + list_ForEach(listEntry, pet->tags) { + tag_free(listEntry->data); + } + list_freeList(pet->tags); + pet->tags = NULL; + } + free(pet); +} + +cJSON *pet_convertToJSON(pet_t *pet) { + cJSON *item = cJSON_CreateObject(); + + // pet->id + if(pet->id) { + if(cJSON_AddNumberToObject(item, "id", pet->id) == NULL) { + goto fail; //Numeric + } + } + + + // pet->category + if(pet->category) { + cJSON *category_local_JSON = category_convertToJSON(pet->category); + if(category_local_JSON == NULL) { + goto fail; //model + } + cJSON_AddItemToObject(item, "category", category_local_JSON); + if(item->child == NULL) { + goto fail; + } + } + + + // pet->name + if (!pet->name) { + goto fail; + } + if(cJSON_AddStringToObject(item, "name", pet->name) == NULL) { + goto fail; //String + } + + + // pet->photo_urls + if (!pet->photo_urls) { + goto fail; + } + cJSON *photo_urls = cJSON_AddArrayToObject(item, "photoUrls"); + if(photo_urls == NULL) { + goto fail; //primitive container + } + + listEntry_t *photo_urlsListEntry; + list_ForEach(photo_urlsListEntry, pet->photo_urls) { + if(cJSON_AddStringToObject(photo_urls, "", photo_urlsListEntry->data) == NULL) + { + goto fail; + } + } + + + // pet->tags + if(pet->tags) { + cJSON *tags = cJSON_AddArrayToObject(item, "tags"); + if(tags == NULL) { + goto fail; //nonprimitive container + } + + listEntry_t *tagsListEntry; + if (pet->tags) { + list_ForEach(tagsListEntry, pet->tags) { + cJSON *itemLocal = tag_convertToJSON(tagsListEntry->data); + if(itemLocal == NULL) { + goto fail; + } + cJSON_AddItemToArray(tags, itemLocal); + } + } + } + + + // pet->status + if(pet->status != openapi_petstore_pet_STATUS_NULL) { + if(cJSON_AddStringToObject(item, "status", pet_status_ToString(pet->status)) == NULL) + { + goto fail; //Enum + } + } + + return item; +fail: + if (item) { + cJSON_Delete(item); + } + return NULL; +} + +pet_t *pet_parseFromJSON(cJSON *petJSON){ + + pet_t *pet_local_var = NULL; + + // define the local variable for pet->category + category_t *category_local_nonprim = NULL; + + // define the local list for pet->photo_urls + list_t *photo_urlsList = NULL; + + // define the local list for pet->tags + list_t *tagsList = NULL; + + // pet->id + cJSON *id = cJSON_GetObjectItemCaseSensitive(petJSON, "id"); + if (cJSON_IsNull(id)) { + id = NULL; + } + if (id) { + if(!cJSON_IsNumber(id)) + { + goto end; //Numeric + } + } + + // pet->category + cJSON *category = cJSON_GetObjectItemCaseSensitive(petJSON, "category"); + if (cJSON_IsNull(category)) { + category = NULL; + } + if (category) { + category_local_nonprim = category_parseFromJSON(category); //nonprimitive + } + + // pet->name + cJSON *name = cJSON_GetObjectItemCaseSensitive(petJSON, "name"); + if (cJSON_IsNull(name)) { + name = NULL; + } + if (!name) { + goto end; + } + + + if(!cJSON_IsString(name)) + { + goto end; //String + } + + // pet->photo_urls + cJSON *photo_urls = cJSON_GetObjectItemCaseSensitive(petJSON, "photoUrls"); + if (cJSON_IsNull(photo_urls)) { + photo_urls = NULL; + } + if (!photo_urls) { + goto end; + } + + + cJSON *photo_urls_local = NULL; + if(!cJSON_IsArray(photo_urls)) { + goto end;//primitive container + } + photo_urlsList = list_createList(); + + cJSON_ArrayForEach(photo_urls_local, photo_urls) + { + if(!cJSON_IsString(photo_urls_local)) + { + goto end; + } + list_addElement(photo_urlsList , strdup(photo_urls_local->valuestring)); + } + + // pet->tags + cJSON *tags = cJSON_GetObjectItemCaseSensitive(petJSON, "tags"); + if (cJSON_IsNull(tags)) { + tags = NULL; + } + if (tags) { + cJSON *tags_local_nonprimitive = NULL; + if(!cJSON_IsArray(tags)){ + goto end; //nonprimitive container + } + + tagsList = list_createList(); + + cJSON_ArrayForEach(tags_local_nonprimitive,tags ) + { + if(!cJSON_IsObject(tags_local_nonprimitive)){ + goto end; + } + tag_t *tagsItem = tag_parseFromJSON(tags_local_nonprimitive); + + list_addElement(tagsList, tagsItem); + } + } + + // pet->status + cJSON *status = cJSON_GetObjectItemCaseSensitive(petJSON, "status"); + if (cJSON_IsNull(status)) { + status = NULL; + } + openapi_petstore_pet_STATUS_e statusVariable; + if (status) { + if(!cJSON_IsString(status)) + { + goto end; //Enum + } + statusVariable = pet_status_FromString(status->valuestring); + } + + + pet_local_var = pet_create_internal ( + id ? id->valuedouble : 0, + category ? category_local_nonprim : NULL, + strdup(name->valuestring), + photo_urlsList, + tags ? tagsList : NULL, + status ? statusVariable : openapi_petstore_pet_STATUS_NULL + ); + + return pet_local_var; +end: + if (category_local_nonprim) { + category_free(category_local_nonprim); + category_local_nonprim = NULL; + } + if (photo_urlsList) { + listEntry_t *listEntry = NULL; + list_ForEach(listEntry, photo_urlsList) { + free(listEntry->data); + listEntry->data = NULL; + } + list_freeList(photo_urlsList); + photo_urlsList = NULL; + } + if (tagsList) { + listEntry_t *listEntry = NULL; + list_ForEach(listEntry, tagsList) { + tag_free(listEntry->data); + listEntry->data = NULL; + } + list_freeList(tagsList); + tagsList = NULL; + } + return NULL; + +} diff --git a/samples/client/petstore/c/model/category.c b/samples/client/petstore/c/model/category.c index e69de29bb2d1..2b060a568015 100644 --- a/samples/client/petstore/c/model/category.c +++ b/samples/client/petstore/c/model/category.c @@ -0,0 +1,113 @@ +#include +#include +#include +#include "category.h" + + + +static category_t *category_create_internal( + long id, + char *name + ) { + category_t *category_local_var = malloc(sizeof(category_t)); + if (!category_local_var) { + return NULL; + } + category_local_var->id = id; + category_local_var->name = name; + + category_local_var->_library_owned = 1; + return category_local_var; +} + +__attribute__((deprecated)) category_t *category_create( + long id, + char *name + ) { + return category_create_internal ( + id, + name + ); +} + +void category_free(category_t *category) { + if(NULL == category){ + return ; + } + if(category->_library_owned != 1){ + fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "category_free"); + return ; + } + listEntry_t *listEntry; + if (category->name) { + free(category->name); + category->name = NULL; + } + free(category); +} + +cJSON *category_convertToJSON(category_t *category) { + cJSON *item = cJSON_CreateObject(); + + // category->id + if(category->id) { + if(cJSON_AddNumberToObject(item, "id", category->id) == NULL) { + goto fail; //Numeric + } + } + + + // category->name + if(category->name) { + if(cJSON_AddStringToObject(item, "name", category->name) == NULL) { + goto fail; //String + } + } + + return item; +fail: + if (item) { + cJSON_Delete(item); + } + return NULL; +} + +category_t *category_parseFromJSON(cJSON *categoryJSON){ + + category_t *category_local_var = NULL; + + // category->id + cJSON *id = cJSON_GetObjectItemCaseSensitive(categoryJSON, "id"); + if (cJSON_IsNull(id)) { + id = NULL; + } + if (id) { + if(!cJSON_IsNumber(id)) + { + goto end; //Numeric + } + } + + // category->name + cJSON *name = cJSON_GetObjectItemCaseSensitive(categoryJSON, "name"); + if (cJSON_IsNull(name)) { + name = NULL; + } + if (name) { + if(!cJSON_IsString(name) && !cJSON_IsNull(name)) + { + goto end; //String + } + } + + + category_local_var = category_create_internal ( + id ? id->valuedouble : 0, + name && !cJSON_IsNull(name) ? strdup(name->valuestring) : NULL + ); + + return category_local_var; +end: + return NULL; + +} diff --git a/samples/client/petstore/cpp-oatpp/api/StoreApi.hpp b/samples/client/petstore/cpp-oatpp/api/StoreApi.hpp index e69de29bb2d1..f48ec25ab0ab 100644 --- a/samples/client/petstore/cpp-oatpp/api/StoreApi.hpp +++ b/samples/client/petstore/cpp-oatpp/api/StoreApi.hpp @@ -0,0 +1,77 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* 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. +*/ +/* + * StoreApi.h + * + * + */ + +#ifndef StoreApi_H_ +#define StoreApi_H_ + + + +#include "oatpp/web/client/ApiClient.hpp" +#include "oatpp/web/protocol/http/outgoing/MultipartBody.hpp" +#include "oatpp/core/macro/codegen.hpp" + +#include "Order.hpp" + +#include OATPP_CODEGEN_BEGIN(ApiClient) ///< Begin code-gen section + +namespace org::openapitools::client::api +{ + +class StoreApi : public oatpp::web::client::ApiClient { +public: + + API_CLIENT_INIT(StoreApi) + + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + API_CALL("DELETE", "/store/order/{orderId}", delete_order, PATH(oatpp::String, orderId)) + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + API_CALL("GET", "/store/inventory", get_inventory) + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions + /// + /// ID of pet that needs to be fetched + API_CALL("GET", "/store/order/{orderId}", get_order_by_id, PATH(oatpp::Int64, orderId)) + /// + /// Place an order for a pet + /// + /// + /// + /// + /// order placed for purchasing the pet + API_CALL("POST", "/store/order", place_order, BODY_DTO(oatpp::Object, order)) +}; + +#include OATPP_CODEGEN_END(ApiClient) ///< End code-gen section + +} // namespace org::openapitools::client::api + +#endif /* StoreApi_H_ */ + diff --git a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp index e69de29bb2d1..8fbef0fb8c5c 100644 --- a/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp +++ b/samples/client/petstore/cpp-qt-addDownloadProgress/client/PFXApiResponse.cpp @@ -0,0 +1,160 @@ +/** + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * 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. + */ + +#include "PFXApiResponse.h" + +#include +#include +#include +#include + +#include "PFXHelpers.h" + +namespace test_namespace { + +PFXApiResponse::PFXApiResponse(QString json) { + this->initializeModel(); + this->fromJson(json); +} + +PFXApiResponse::PFXApiResponse() { + this->initializeModel(); +} + +PFXApiResponse::~PFXApiResponse() {} + +void PFXApiResponse::initializeModel() { + + m_code_isSet = false; + m_code_isValid = false; + + m_type_isSet = false; + m_type_isValid = false; + + m_message_isSet = false; + m_message_isValid = false; +} + +void PFXApiResponse::fromJson(QString jsonString) { + QByteArray array(jsonString.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); +} + +void PFXApiResponse::fromJsonObject(QJsonObject json) { + + m_code_isValid = ::test_namespace::fromJsonValue(m_code, json[QString("code")]); + m_code_isSet = !json[QString("code")].isNull() && m_code_isValid; + + m_type_isValid = ::test_namespace::fromJsonValue(m_type, json[QString("type")]); + m_type_isSet = !json[QString("type")].isNull() && m_type_isValid; + + m_message_isValid = ::test_namespace::fromJsonValue(m_message, json[QString("message")]); + m_message_isSet = !json[QString("message")].isNull() && m_message_isValid; +} + +QString PFXApiResponse::asJson() const { + QJsonObject obj = this->asJsonObject(); + QJsonDocument doc(obj); + QByteArray bytes = doc.toJson(); + return QString(bytes); +} + +QJsonObject PFXApiResponse::asJsonObject() const { + QJsonObject obj; + if (m_code_isSet) { + obj.insert(QString("code"), ::test_namespace::toJsonValue(m_code)); + } + if (m_type_isSet) { + obj.insert(QString("type"), ::test_namespace::toJsonValue(m_type)); + } + if (m_message_isSet) { + obj.insert(QString("message"), ::test_namespace::toJsonValue(m_message)); + } + return obj; +} + +qint32 PFXApiResponse::getCode() const { + return m_code; +} +void PFXApiResponse::setCode(const qint32 &code) { + m_code = code; + m_code_isSet = true; +} + +bool PFXApiResponse::is_code_Set() const{ + return m_code_isSet; +} + +bool PFXApiResponse::is_code_Valid() const{ + return m_code_isValid; +} + +QString PFXApiResponse::getType() const { + return m_type; +} +void PFXApiResponse::setType(const QString &type) { + m_type = type; + m_type_isSet = true; +} + +bool PFXApiResponse::is_type_Set() const{ + return m_type_isSet; +} + +bool PFXApiResponse::is_type_Valid() const{ + return m_type_isValid; +} + +QString PFXApiResponse::getMessage() const { + return m_message; +} +void PFXApiResponse::setMessage(const QString &message) { + m_message = message; + m_message_isSet = true; +} + +bool PFXApiResponse::is_message_Set() const{ + return m_message_isSet; +} + +bool PFXApiResponse::is_message_Valid() const{ + return m_message_isValid; +} + +bool PFXApiResponse::isSet() const { + bool isObjectUpdated = false; + do { + if (m_code_isSet) { + isObjectUpdated = true; + break; + } + + if (m_type_isSet) { + isObjectUpdated = true; + break; + } + + if (m_message_isSet) { + isObjectUpdated = true; + break; + } + } while (false); + return isObjectUpdated; +} + +bool PFXApiResponse::isValid() const { + // only required properties are required for the object to be considered valid + return true; +} + +} // namespace test_namespace diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesAnyType.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesAnyType.md index 314cba3a614c..b94c1e6d7d19 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesAnyType.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesAnyType.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_any_type import AdditionalPropert # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesAnyType from a JSON string -additional_properties_any_type_instance = AdditionalPropertiesAnyType.from_json(json) +additional_properties_any_type_instance = AdditionalPropertiesAnyType.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesAnyType.to_json()) +print(additional_properties_any_type_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_any_type_dict = additional_properties_any_type_instance.to_dict() +additional_properties_any_type_dict = additional_properties_any_type_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesAnyType from a dict -additional_properties_any_type_from_dict = AdditionalPropertiesAnyType.from_dict(additional_properties_any_type_dict) +additional_properties_any_type_from_dict = AdditionalPropertiesAnyType.model_validate(additional_properties_any_type_dict) ``` [[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-aiohttp/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesClass.md index 8d4c08707f55..4c880d6853e8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesClass.md @@ -16,14 +16,14 @@ from petstore_api.models.additional_properties_class import AdditionalProperties # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesClass from a JSON string -additional_properties_class_instance = AdditionalPropertiesClass.from_json(json) +additional_properties_class_instance = AdditionalPropertiesClass.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesClass.to_json()) +print(additional_properties_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_class_dict = additional_properties_class_instance.to_dict() +additional_properties_class_dict = additional_properties_class_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesClass from a dict -additional_properties_class_from_dict = AdditionalPropertiesClass.from_dict(additional_properties_class_dict) +additional_properties_class_from_dict = AdditionalPropertiesClass.model_validate(additional_properties_class_dict) ``` [[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-aiohttp/docs/AdditionalPropertiesObject.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesObject.md index d647ec64896f..bf6743709338 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesObject.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesObject.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_object import AdditionalPropertie # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesObject from a JSON string -additional_properties_object_instance = AdditionalPropertiesObject.from_json(json) +additional_properties_object_instance = AdditionalPropertiesObject.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesObject.to_json()) +print(additional_properties_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_object_dict = additional_properties_object_instance.to_dict() +additional_properties_object_dict = additional_properties_object_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesObject from a dict -additional_properties_object_from_dict = AdditionalPropertiesObject.from_dict(additional_properties_object_dict) +additional_properties_object_from_dict = AdditionalPropertiesObject.model_validate(additional_properties_object_dict) ``` [[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-aiohttp/docs/AdditionalPropertiesWithDescriptionOnly.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesWithDescriptionOnly.md index 061f5524872b..1cb2a02f7584 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesWithDescriptionOnly.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesWithDescriptionOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_with_description_only import Addi # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string -additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.from_json(json) +additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesWithDescriptionOnly.to_json()) +print(additional_properties_with_description_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.to_dict() +additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesWithDescriptionOnly from a dict -additional_properties_with_description_only_from_dict = AdditionalPropertiesWithDescriptionOnly.from_dict(additional_properties_with_description_only_dict) +additional_properties_with_description_only_from_dict = AdditionalPropertiesWithDescriptionOnly.model_validate(additional_properties_with_description_only_dict) ``` [[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-aiohttp/docs/AllOfSuperModel.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AllOfSuperModel.md index 421a1527f1ef..88cb95097517 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/AllOfSuperModel.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AllOfSuperModel.md @@ -15,14 +15,14 @@ from petstore_api.models.all_of_super_model import AllOfSuperModel # TODO update the JSON string below json = "{}" # create an instance of AllOfSuperModel from a JSON string -all_of_super_model_instance = AllOfSuperModel.from_json(json) +all_of_super_model_instance = AllOfSuperModel.model_validate_json(json) # print the JSON string representation of the object -print(AllOfSuperModel.to_json()) +print(all_of_super_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -all_of_super_model_dict = all_of_super_model_instance.to_dict() +all_of_super_model_dict = all_of_super_model_instance.model_dump(by_alias=True) # create an instance of AllOfSuperModel from a dict -all_of_super_model_from_dict = AllOfSuperModel.from_dict(all_of_super_model_dict) +all_of_super_model_from_dict = AllOfSuperModel.model_validate(all_of_super_model_dict) ``` [[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-aiohttp/docs/AllOfWithSingleRef.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AllOfWithSingleRef.md index 203a4b5da3d5..dd0f755dfe65 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/AllOfWithSingleRef.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AllOfWithSingleRef.md @@ -16,14 +16,14 @@ from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef # TODO update the JSON string below json = "{}" # create an instance of AllOfWithSingleRef from a JSON string -all_of_with_single_ref_instance = AllOfWithSingleRef.from_json(json) +all_of_with_single_ref_instance = AllOfWithSingleRef.model_validate_json(json) # print the JSON string representation of the object -print(AllOfWithSingleRef.to_json()) +print(all_of_with_single_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -all_of_with_single_ref_dict = all_of_with_single_ref_instance.to_dict() +all_of_with_single_ref_dict = all_of_with_single_ref_instance.model_dump(by_alias=True) # create an instance of AllOfWithSingleRef from a dict -all_of_with_single_ref_from_dict = AllOfWithSingleRef.from_dict(all_of_with_single_ref_dict) +all_of_with_single_ref_from_dict = AllOfWithSingleRef.model_validate(all_of_with_single_ref_dict) ``` [[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-aiohttp/docs/Animal.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Animal.md index 381d27b66e44..fcded75f52be 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Animal.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Animal.md @@ -16,14 +16,14 @@ from petstore_api.models.animal import Animal # TODO update the JSON string below json = "{}" # create an instance of Animal from a JSON string -animal_instance = Animal.from_json(json) +animal_instance = Animal.model_validate_json(json) # print the JSON string representation of the object -print(Animal.to_json()) +print(animal_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -animal_dict = animal_instance.to_dict() +animal_dict = animal_instance.model_dump(by_alias=True) # create an instance of Animal from a dict -animal_from_dict = Animal.from_dict(animal_dict) +animal_from_dict = Animal.model_validate(animal_dict) ``` [[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-aiohttp/docs/AnyOfColor.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AnyOfColor.md index 6ed75dd7b48a..02aab883b2b0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/AnyOfColor.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AnyOfColor.md @@ -15,14 +15,14 @@ from petstore_api.models.any_of_color import AnyOfColor # TODO update the JSON string below json = "{}" # create an instance of AnyOfColor from a JSON string -any_of_color_instance = AnyOfColor.from_json(json) +any_of_color_instance = AnyOfColor.model_validate_json(json) # print the JSON string representation of the object -print(AnyOfColor.to_json()) +print(any_of_color_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -any_of_color_dict = any_of_color_instance.to_dict() +any_of_color_dict = any_of_color_instance.model_dump(by_alias=True) # create an instance of AnyOfColor from a dict -any_of_color_from_dict = AnyOfColor.from_dict(any_of_color_dict) +any_of_color_from_dict = AnyOfColor.model_validate(any_of_color_dict) ``` [[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-aiohttp/docs/AnyOfPig.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AnyOfPig.md index 9367e2261898..db2878121f29 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/AnyOfPig.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AnyOfPig.md @@ -17,14 +17,14 @@ from petstore_api.models.any_of_pig import AnyOfPig # TODO update the JSON string below json = "{}" # create an instance of AnyOfPig from a JSON string -any_of_pig_instance = AnyOfPig.from_json(json) +any_of_pig_instance = AnyOfPig.model_validate_json(json) # print the JSON string representation of the object -print(AnyOfPig.to_json()) +print(any_of_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -any_of_pig_dict = any_of_pig_instance.to_dict() +any_of_pig_dict = any_of_pig_instance.model_dump(by_alias=True) # create an instance of AnyOfPig from a dict -any_of_pig_from_dict = AnyOfPig.from_dict(any_of_pig_dict) +any_of_pig_from_dict = AnyOfPig.model_validate(any_of_pig_dict) ``` [[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-aiohttp/docs/ArrayOfArrayOfModel.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfArrayOfModel.md index f866863d53f9..e8274d8fbb52 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfArrayOfModel.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfArrayOfModel.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel # TODO update the JSON string below json = "{}" # create an instance of ArrayOfArrayOfModel from a JSON string -array_of_array_of_model_instance = ArrayOfArrayOfModel.from_json(json) +array_of_array_of_model_instance = ArrayOfArrayOfModel.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfArrayOfModel.to_json()) +print(array_of_array_of_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_array_of_model_dict = array_of_array_of_model_instance.to_dict() +array_of_array_of_model_dict = array_of_array_of_model_instance.model_dump(by_alias=True) # create an instance of ArrayOfArrayOfModel from a dict -array_of_array_of_model_from_dict = ArrayOfArrayOfModel.from_dict(array_of_array_of_model_dict) +array_of_array_of_model_from_dict = ArrayOfArrayOfModel.model_validate(array_of_array_of_model_dict) ``` [[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-aiohttp/docs/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfArrayOfNumberOnly.md index 32bd2dfbf1e2..8931a1c7e467 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfArrayOfNumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb # TODO update the JSON string below json = "{}" # create an instance of ArrayOfArrayOfNumberOnly from a JSON string -array_of_array_of_number_only_instance = ArrayOfArrayOfNumberOnly.from_json(json) +array_of_array_of_number_only_instance = ArrayOfArrayOfNumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfArrayOfNumberOnly.to_json()) +print(array_of_array_of_number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_array_of_number_only_dict = array_of_array_of_number_only_instance.to_dict() +array_of_array_of_number_only_dict = array_of_array_of_number_only_instance.model_dump(by_alias=True) # create an instance of ArrayOfArrayOfNumberOnly from a dict -array_of_array_of_number_only_from_dict = ArrayOfArrayOfNumberOnly.from_dict(array_of_array_of_number_only_dict) +array_of_array_of_number_only_from_dict = ArrayOfArrayOfNumberOnly.model_validate(array_of_array_of_number_only_dict) ``` [[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-aiohttp/docs/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfNumberOnly.md index b814d7594942..a709583be699 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayOfNumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_number_only import ArrayOfNumberOnly # TODO update the JSON string below json = "{}" # create an instance of ArrayOfNumberOnly from a JSON string -array_of_number_only_instance = ArrayOfNumberOnly.from_json(json) +array_of_number_only_instance = ArrayOfNumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfNumberOnly.to_json()) +print(array_of_number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_number_only_dict = array_of_number_only_instance.to_dict() +array_of_number_only_dict = array_of_number_only_instance.model_dump(by_alias=True) # create an instance of ArrayOfNumberOnly from a dict -array_of_number_only_from_dict = ArrayOfNumberOnly.from_dict(array_of_number_only_dict) +array_of_number_only_from_dict = ArrayOfNumberOnly.model_validate(array_of_number_only_dict) ``` [[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-aiohttp/docs/ArrayTest.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayTest.md index ed871fae662d..a99eb056c5ca 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayTest.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ArrayTest.md @@ -18,14 +18,14 @@ from petstore_api.models.array_test import ArrayTest # TODO update the JSON string below json = "{}" # create an instance of ArrayTest from a JSON string -array_test_instance = ArrayTest.from_json(json) +array_test_instance = ArrayTest.model_validate_json(json) # print the JSON string representation of the object -print(ArrayTest.to_json()) +print(array_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_test_dict = array_test_instance.to_dict() +array_test_dict = array_test_instance.model_dump(by_alias=True) # create an instance of ArrayTest from a dict -array_test_from_dict = ArrayTest.from_dict(array_test_dict) +array_test_from_dict = ArrayTest.model_validate(array_test_dict) ``` [[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-aiohttp/docs/BaseDiscriminator.md b/samples/openapi3/client/petstore/python-aiohttp/docs/BaseDiscriminator.md index fcdbeb032e68..0482396cbcf8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/BaseDiscriminator.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/BaseDiscriminator.md @@ -15,14 +15,14 @@ from petstore_api.models.base_discriminator import BaseDiscriminator # TODO update the JSON string below json = "{}" # create an instance of BaseDiscriminator from a JSON string -base_discriminator_instance = BaseDiscriminator.from_json(json) +base_discriminator_instance = BaseDiscriminator.model_validate_json(json) # print the JSON string representation of the object -print(BaseDiscriminator.to_json()) +print(base_discriminator_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -base_discriminator_dict = base_discriminator_instance.to_dict() +base_discriminator_dict = base_discriminator_instance.model_dump(by_alias=True) # create an instance of BaseDiscriminator from a dict -base_discriminator_from_dict = BaseDiscriminator.from_dict(base_discriminator_dict) +base_discriminator_from_dict = BaseDiscriminator.model_validate(base_discriminator_dict) ``` [[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-aiohttp/docs/BasquePig.md b/samples/openapi3/client/petstore/python-aiohttp/docs/BasquePig.md index ee28d628722f..9844d05b3740 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/BasquePig.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/BasquePig.md @@ -16,14 +16,14 @@ from petstore_api.models.basque_pig import BasquePig # TODO update the JSON string below json = "{}" # create an instance of BasquePig from a JSON string -basque_pig_instance = BasquePig.from_json(json) +basque_pig_instance = BasquePig.model_validate_json(json) # print the JSON string representation of the object -print(BasquePig.to_json()) +print(basque_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -basque_pig_dict = basque_pig_instance.to_dict() +basque_pig_dict = basque_pig_instance.model_dump(by_alias=True) # create an instance of BasquePig from a dict -basque_pig_from_dict = BasquePig.from_dict(basque_pig_dict) +basque_pig_from_dict = BasquePig.model_validate(basque_pig_dict) ``` [[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-aiohttp/docs/Bathing.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Bathing.md index 6ad70e2f67cc..2c8d8332629b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Bathing.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Bathing.md @@ -17,14 +17,14 @@ from petstore_api.models.bathing import Bathing # TODO update the JSON string below json = "{}" # create an instance of Bathing from a JSON string -bathing_instance = Bathing.from_json(json) +bathing_instance = Bathing.model_validate_json(json) # print the JSON string representation of the object -print(Bathing.to_json()) +print(bathing_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -bathing_dict = bathing_instance.to_dict() +bathing_dict = bathing_instance.model_dump(by_alias=True) # create an instance of Bathing from a dict -bathing_from_dict = Bathing.from_dict(bathing_dict) +bathing_from_dict = Bathing.model_validate(bathing_dict) ``` [[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-aiohttp/docs/Capitalization.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Capitalization.md index 6f564a8ed8c9..55fcc0c01cb2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Capitalization.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Capitalization.md @@ -20,14 +20,14 @@ from petstore_api.models.capitalization import Capitalization # TODO update the JSON string below json = "{}" # create an instance of Capitalization from a JSON string -capitalization_instance = Capitalization.from_json(json) +capitalization_instance = Capitalization.model_validate_json(json) # print the JSON string representation of the object -print(Capitalization.to_json()) +print(capitalization_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -capitalization_dict = capitalization_instance.to_dict() +capitalization_dict = capitalization_instance.model_dump(by_alias=True) # create an instance of Capitalization from a dict -capitalization_from_dict = Capitalization.from_dict(capitalization_dict) +capitalization_from_dict = Capitalization.model_validate(capitalization_dict) ``` [[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-aiohttp/docs/Cat.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Cat.md index d0e39efdb33e..0845d68bd487 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Cat.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Cat.md @@ -15,14 +15,14 @@ from petstore_api.models.cat import Cat # TODO update the JSON string below json = "{}" # create an instance of Cat from a JSON string -cat_instance = Cat.from_json(json) +cat_instance = Cat.model_validate_json(json) # print the JSON string representation of the object -print(Cat.to_json()) +print(cat_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -cat_dict = cat_instance.to_dict() +cat_dict = cat_instance.model_dump(by_alias=True) # create an instance of Cat from a dict -cat_from_dict = Cat.from_dict(cat_dict) +cat_from_dict = Cat.model_validate(cat_dict) ``` [[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-aiohttp/docs/Category.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Category.md index dbde14b7344c..8a14791c7925 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Category.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Category.md @@ -16,14 +16,14 @@ from petstore_api.models.category import Category # TODO update the JSON string below json = "{}" # create an instance of Category from a JSON string -category_instance = Category.from_json(json) +category_instance = Category.model_validate_json(json) # print the JSON string representation of the object -print(Category.to_json()) +print(category_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -category_dict = category_instance.to_dict() +category_dict = category_instance.model_dump(by_alias=True) # create an instance of Category from a dict -category_from_dict = Category.from_dict(category_dict) +category_from_dict = Category.model_validate(category_dict) ``` [[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-aiohttp/docs/CircularAllOfRef.md b/samples/openapi3/client/petstore/python-aiohttp/docs/CircularAllOfRef.md index 65b171177e58..f937a53cfe3c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/CircularAllOfRef.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/CircularAllOfRef.md @@ -16,14 +16,14 @@ from petstore_api.models.circular_all_of_ref import CircularAllOfRef # TODO update the JSON string below json = "{}" # create an instance of CircularAllOfRef from a JSON string -circular_all_of_ref_instance = CircularAllOfRef.from_json(json) +circular_all_of_ref_instance = CircularAllOfRef.model_validate_json(json) # print the JSON string representation of the object -print(CircularAllOfRef.to_json()) +print(circular_all_of_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -circular_all_of_ref_dict = circular_all_of_ref_instance.to_dict() +circular_all_of_ref_dict = circular_all_of_ref_instance.model_dump(by_alias=True) # create an instance of CircularAllOfRef from a dict -circular_all_of_ref_from_dict = CircularAllOfRef.from_dict(circular_all_of_ref_dict) +circular_all_of_ref_from_dict = CircularAllOfRef.model_validate(circular_all_of_ref_dict) ``` [[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-aiohttp/docs/CircularReferenceModel.md b/samples/openapi3/client/petstore/python-aiohttp/docs/CircularReferenceModel.md index 87216f7273ab..9a39f46e5d7d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/CircularReferenceModel.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/CircularReferenceModel.md @@ -16,14 +16,14 @@ from petstore_api.models.circular_reference_model import CircularReferenceModel # TODO update the JSON string below json = "{}" # create an instance of CircularReferenceModel from a JSON string -circular_reference_model_instance = CircularReferenceModel.from_json(json) +circular_reference_model_instance = CircularReferenceModel.model_validate_json(json) # print the JSON string representation of the object -print(CircularReferenceModel.to_json()) +print(circular_reference_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -circular_reference_model_dict = circular_reference_model_instance.to_dict() +circular_reference_model_dict = circular_reference_model_instance.model_dump(by_alias=True) # create an instance of CircularReferenceModel from a dict -circular_reference_model_from_dict = CircularReferenceModel.from_dict(circular_reference_model_dict) +circular_reference_model_from_dict = CircularReferenceModel.model_validate(circular_reference_model_dict) ``` [[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-aiohttp/docs/ClassModel.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ClassModel.md index ea76a5c157bf..50fbfefa7661 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ClassModel.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ClassModel.md @@ -16,14 +16,14 @@ from petstore_api.models.class_model import ClassModel # TODO update the JSON string below json = "{}" # create an instance of ClassModel from a JSON string -class_model_instance = ClassModel.from_json(json) +class_model_instance = ClassModel.model_validate_json(json) # print the JSON string representation of the object -print(ClassModel.to_json()) +print(class_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -class_model_dict = class_model_instance.to_dict() +class_model_dict = class_model_instance.model_dump(by_alias=True) # create an instance of ClassModel from a dict -class_model_from_dict = ClassModel.from_dict(class_model_dict) +class_model_from_dict = ClassModel.model_validate(class_model_dict) ``` [[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-aiohttp/docs/Client.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Client.md index 22321c189150..160a80da457f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Client.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Client.md @@ -15,14 +15,14 @@ from petstore_api.models.client import Client # TODO update the JSON string below json = "{}" # create an instance of Client from a JSON string -client_instance = Client.from_json(json) +client_instance = Client.model_validate_json(json) # print the JSON string representation of the object -print(Client.to_json()) +print(client_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -client_dict = client_instance.to_dict() +client_dict = client_instance.model_dump(by_alias=True) # create an instance of Client from a dict -client_from_dict = Client.from_dict(client_dict) +client_from_dict = Client.model_validate(client_dict) ``` [[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-aiohttp/docs/Color.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Color.md index 9ac3ab2e91f4..1425ff185040 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Color.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Color.md @@ -15,14 +15,14 @@ from petstore_api.models.color import Color # TODO update the JSON string below json = "{}" # create an instance of Color from a JSON string -color_instance = Color.from_json(json) +color_instance = Color.model_validate_json(json) # print the JSON string representation of the object -print(Color.to_json()) +print(color_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -color_dict = color_instance.to_dict() +color_dict = color_instance.model_dump(by_alias=True) # create an instance of Color from a dict -color_from_dict = Color.from_dict(color_dict) +color_from_dict = Color.model_validate(color_dict) ``` [[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-aiohttp/docs/Creature.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Creature.md index a4710214c198..eb0ba3b2f127 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Creature.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Creature.md @@ -16,14 +16,14 @@ from petstore_api.models.creature import Creature # TODO update the JSON string below json = "{}" # create an instance of Creature from a JSON string -creature_instance = Creature.from_json(json) +creature_instance = Creature.model_validate_json(json) # print the JSON string representation of the object -print(Creature.to_json()) +print(creature_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -creature_dict = creature_instance.to_dict() +creature_dict = creature_instance.model_dump(by_alias=True) # create an instance of Creature from a dict -creature_from_dict = Creature.from_dict(creature_dict) +creature_from_dict = Creature.model_validate(creature_dict) ``` [[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-aiohttp/docs/CreatureInfo.md b/samples/openapi3/client/petstore/python-aiohttp/docs/CreatureInfo.md index db3b82bb9ff5..156d93939201 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/CreatureInfo.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/CreatureInfo.md @@ -15,14 +15,14 @@ from petstore_api.models.creature_info import CreatureInfo # TODO update the JSON string below json = "{}" # create an instance of CreatureInfo from a JSON string -creature_info_instance = CreatureInfo.from_json(json) +creature_info_instance = CreatureInfo.model_validate_json(json) # print the JSON string representation of the object -print(CreatureInfo.to_json()) +print(creature_info_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -creature_info_dict = creature_info_instance.to_dict() +creature_info_dict = creature_info_instance.model_dump(by_alias=True) # create an instance of CreatureInfo from a dict -creature_info_from_dict = CreatureInfo.from_dict(creature_info_dict) +creature_info_from_dict = CreatureInfo.model_validate(creature_info_dict) ``` [[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-aiohttp/docs/DanishPig.md b/samples/openapi3/client/petstore/python-aiohttp/docs/DanishPig.md index 16941388832a..5eac27f79e79 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/DanishPig.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/DanishPig.md @@ -16,14 +16,14 @@ from petstore_api.models.danish_pig import DanishPig # TODO update the JSON string below json = "{}" # create an instance of DanishPig from a JSON string -danish_pig_instance = DanishPig.from_json(json) +danish_pig_instance = DanishPig.model_validate_json(json) # print the JSON string representation of the object -print(DanishPig.to_json()) +print(danish_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -danish_pig_dict = danish_pig_instance.to_dict() +danish_pig_dict = danish_pig_instance.model_dump(by_alias=True) # create an instance of DanishPig from a dict -danish_pig_from_dict = DanishPig.from_dict(danish_pig_dict) +danish_pig_from_dict = DanishPig.model_validate(danish_pig_dict) ``` [[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-aiohttp/docs/DeprecatedObject.md b/samples/openapi3/client/petstore/python-aiohttp/docs/DeprecatedObject.md index 6b362f379ba4..ff3aa9812e2d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/DeprecatedObject.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/DeprecatedObject.md @@ -15,14 +15,14 @@ from petstore_api.models.deprecated_object import DeprecatedObject # TODO update the JSON string below json = "{}" # create an instance of DeprecatedObject from a JSON string -deprecated_object_instance = DeprecatedObject.from_json(json) +deprecated_object_instance = DeprecatedObject.model_validate_json(json) # print the JSON string representation of the object -print(DeprecatedObject.to_json()) +print(deprecated_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -deprecated_object_dict = deprecated_object_instance.to_dict() +deprecated_object_dict = deprecated_object_instance.model_dump(by_alias=True) # create an instance of DeprecatedObject from a dict -deprecated_object_from_dict = DeprecatedObject.from_dict(deprecated_object_dict) +deprecated_object_from_dict = DeprecatedObject.model_validate(deprecated_object_dict) ``` [[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-aiohttp/docs/DiscriminatorAllOfSub.md b/samples/openapi3/client/petstore/python-aiohttp/docs/DiscriminatorAllOfSub.md index f72b6e8e68ca..aa7af45b99fa 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/DiscriminatorAllOfSub.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/DiscriminatorAllOfSub.md @@ -14,14 +14,14 @@ from petstore_api.models.discriminator_all_of_sub import DiscriminatorAllOfSub # TODO update the JSON string below json = "{}" # create an instance of DiscriminatorAllOfSub from a JSON string -discriminator_all_of_sub_instance = DiscriminatorAllOfSub.from_json(json) +discriminator_all_of_sub_instance = DiscriminatorAllOfSub.model_validate_json(json) # print the JSON string representation of the object -print(DiscriminatorAllOfSub.to_json()) +print(discriminator_all_of_sub_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -discriminator_all_of_sub_dict = discriminator_all_of_sub_instance.to_dict() +discriminator_all_of_sub_dict = discriminator_all_of_sub_instance.model_dump(by_alias=True) # create an instance of DiscriminatorAllOfSub from a dict -discriminator_all_of_sub_from_dict = DiscriminatorAllOfSub.from_dict(discriminator_all_of_sub_dict) +discriminator_all_of_sub_from_dict = DiscriminatorAllOfSub.model_validate(discriminator_all_of_sub_dict) ``` [[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-aiohttp/docs/DiscriminatorAllOfSuper.md b/samples/openapi3/client/petstore/python-aiohttp/docs/DiscriminatorAllOfSuper.md index 477c05bfc446..c21e5b2296ac 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/DiscriminatorAllOfSuper.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/DiscriminatorAllOfSuper.md @@ -15,14 +15,14 @@ from petstore_api.models.discriminator_all_of_super import DiscriminatorAllOfSup # TODO update the JSON string below json = "{}" # create an instance of DiscriminatorAllOfSuper from a JSON string -discriminator_all_of_super_instance = DiscriminatorAllOfSuper.from_json(json) +discriminator_all_of_super_instance = DiscriminatorAllOfSuper.model_validate_json(json) # print the JSON string representation of the object -print(DiscriminatorAllOfSuper.to_json()) +print(discriminator_all_of_super_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -discriminator_all_of_super_dict = discriminator_all_of_super_instance.to_dict() +discriminator_all_of_super_dict = discriminator_all_of_super_instance.model_dump(by_alias=True) # create an instance of DiscriminatorAllOfSuper from a dict -discriminator_all_of_super_from_dict = DiscriminatorAllOfSuper.from_dict(discriminator_all_of_super_dict) +discriminator_all_of_super_from_dict = DiscriminatorAllOfSuper.model_validate(discriminator_all_of_super_dict) ``` [[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-aiohttp/docs/Dog.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Dog.md index ed23f613d01d..2065d42f5f6b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Dog.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Dog.md @@ -15,14 +15,14 @@ from petstore_api.models.dog import Dog # TODO update the JSON string below json = "{}" # create an instance of Dog from a JSON string -dog_instance = Dog.from_json(json) +dog_instance = Dog.model_validate_json(json) # print the JSON string representation of the object -print(Dog.to_json()) +print(dog_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -dog_dict = dog_instance.to_dict() +dog_dict = dog_instance.model_dump(by_alias=True) # create an instance of Dog from a dict -dog_from_dict = Dog.from_dict(dog_dict) +dog_from_dict = Dog.model_validate(dog_dict) ``` [[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-aiohttp/docs/DummyModel.md b/samples/openapi3/client/petstore/python-aiohttp/docs/DummyModel.md index 01b675977f58..dfe28d9f75b1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/DummyModel.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/DummyModel.md @@ -16,14 +16,14 @@ from petstore_api.models.dummy_model import DummyModel # TODO update the JSON string below json = "{}" # create an instance of DummyModel from a JSON string -dummy_model_instance = DummyModel.from_json(json) +dummy_model_instance = DummyModel.model_validate_json(json) # print the JSON string representation of the object -print(DummyModel.to_json()) +print(dummy_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -dummy_model_dict = dummy_model_instance.to_dict() +dummy_model_dict = dummy_model_instance.model_dump(by_alias=True) # create an instance of DummyModel from a dict -dummy_model_from_dict = DummyModel.from_dict(dummy_model_dict) +dummy_model_from_dict = DummyModel.model_validate(dummy_model_dict) ``` [[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-aiohttp/docs/EnumArrays.md b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumArrays.md index f44617497bce..bf8b1a6cd05c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumArrays.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumArrays.md @@ -16,14 +16,14 @@ from petstore_api.models.enum_arrays import EnumArrays # TODO update the JSON string below json = "{}" # create an instance of EnumArrays from a JSON string -enum_arrays_instance = EnumArrays.from_json(json) +enum_arrays_instance = EnumArrays.model_validate_json(json) # print the JSON string representation of the object -print(EnumArrays.to_json()) +print(enum_arrays_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_arrays_dict = enum_arrays_instance.to_dict() +enum_arrays_dict = enum_arrays_instance.model_dump(by_alias=True) # create an instance of EnumArrays from a dict -enum_arrays_from_dict = EnumArrays.from_dict(enum_arrays_dict) +enum_arrays_from_dict = EnumArrays.model_validate(enum_arrays_dict) ``` [[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-aiohttp/docs/EnumRefWithDefaultValue.md b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumRefWithDefaultValue.md index eeb0dc66969f..cbe6845479eb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumRefWithDefaultValue.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumRefWithDefaultValue.md @@ -15,14 +15,14 @@ from petstore_api.models.enum_ref_with_default_value import EnumRefWithDefaultVa # TODO update the JSON string below json = "{}" # create an instance of EnumRefWithDefaultValue from a JSON string -enum_ref_with_default_value_instance = EnumRefWithDefaultValue.from_json(json) +enum_ref_with_default_value_instance = EnumRefWithDefaultValue.model_validate_json(json) # print the JSON string representation of the object -print(EnumRefWithDefaultValue.to_json()) +print(enum_ref_with_default_value_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_ref_with_default_value_dict = enum_ref_with_default_value_instance.to_dict() +enum_ref_with_default_value_dict = enum_ref_with_default_value_instance.model_dump(by_alias=True) # create an instance of EnumRefWithDefaultValue from a dict -enum_ref_with_default_value_from_dict = EnumRefWithDefaultValue.from_dict(enum_ref_with_default_value_dict) +enum_ref_with_default_value_from_dict = EnumRefWithDefaultValue.model_validate(enum_ref_with_default_value_dict) ``` [[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-aiohttp/docs/EnumTest.md b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumTest.md index 9f96c605d888..6ce4891aa9d5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/EnumTest.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/EnumTest.md @@ -27,14 +27,14 @@ from petstore_api.models.enum_test import EnumTest # TODO update the JSON string below json = "{}" # create an instance of EnumTest from a JSON string -enum_test_instance = EnumTest.from_json(json) +enum_test_instance = EnumTest.model_validate_json(json) # print the JSON string representation of the object -print(EnumTest.to_json()) +print(enum_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_test_dict = enum_test_instance.to_dict() +enum_test_dict = enum_test_instance.model_dump(by_alias=True) # create an instance of EnumTest from a dict -enum_test_from_dict = EnumTest.from_dict(enum_test_dict) +enum_test_from_dict = EnumTest.model_validate(enum_test_dict) ``` [[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-aiohttp/docs/Feeding.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Feeding.md index 9f92b5d964d3..773d1373cca0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Feeding.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Feeding.md @@ -17,14 +17,14 @@ from petstore_api.models.feeding import Feeding # TODO update the JSON string below json = "{}" # create an instance of Feeding from a JSON string -feeding_instance = Feeding.from_json(json) +feeding_instance = Feeding.model_validate_json(json) # print the JSON string representation of the object -print(Feeding.to_json()) +print(feeding_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -feeding_dict = feeding_instance.to_dict() +feeding_dict = feeding_instance.model_dump(by_alias=True) # create an instance of Feeding from a dict -feeding_from_dict = Feeding.from_dict(feeding_dict) +feeding_from_dict = Feeding.model_validate(feeding_dict) ``` [[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-aiohttp/docs/File.md b/samples/openapi3/client/petstore/python-aiohttp/docs/File.md index 23f0567411ce..3fe748f4f30f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/File.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/File.md @@ -16,14 +16,14 @@ from petstore_api.models.file import File # TODO update the JSON string below json = "{}" # create an instance of File from a JSON string -file_instance = File.from_json(json) +file_instance = File.model_validate_json(json) # print the JSON string representation of the object -print(File.to_json()) +print(file_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -file_dict = file_instance.to_dict() +file_dict = file_instance.model_dump(by_alias=True) # create an instance of File from a dict -file_from_dict = File.from_dict(file_dict) +file_from_dict = File.model_validate(file_dict) ``` [[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-aiohttp/docs/FileSchemaTestClass.md b/samples/openapi3/client/petstore/python-aiohttp/docs/FileSchemaTestClass.md index e1118042a8ec..78bc4ae135da 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/FileSchemaTestClass.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/FileSchemaTestClass.md @@ -16,14 +16,14 @@ from petstore_api.models.file_schema_test_class import FileSchemaTestClass # TODO update the JSON string below json = "{}" # create an instance of FileSchemaTestClass from a JSON string -file_schema_test_class_instance = FileSchemaTestClass.from_json(json) +file_schema_test_class_instance = FileSchemaTestClass.model_validate_json(json) # print the JSON string representation of the object -print(FileSchemaTestClass.to_json()) +print(file_schema_test_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -file_schema_test_class_dict = file_schema_test_class_instance.to_dict() +file_schema_test_class_dict = file_schema_test_class_instance.model_dump(by_alias=True) # create an instance of FileSchemaTestClass from a dict -file_schema_test_class_from_dict = FileSchemaTestClass.from_dict(file_schema_test_class_dict) +file_schema_test_class_from_dict = FileSchemaTestClass.model_validate(file_schema_test_class_dict) ``` [[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-aiohttp/docs/FirstRef.md b/samples/openapi3/client/petstore/python-aiohttp/docs/FirstRef.md index 94b8ddc5ac22..6da6650e5df7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/FirstRef.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/FirstRef.md @@ -16,14 +16,14 @@ from petstore_api.models.first_ref import FirstRef # TODO update the JSON string below json = "{}" # create an instance of FirstRef from a JSON string -first_ref_instance = FirstRef.from_json(json) +first_ref_instance = FirstRef.model_validate_json(json) # print the JSON string representation of the object -print(FirstRef.to_json()) +print(first_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -first_ref_dict = first_ref_instance.to_dict() +first_ref_dict = first_ref_instance.model_dump(by_alias=True) # create an instance of FirstRef from a dict -first_ref_from_dict = FirstRef.from_dict(first_ref_dict) +first_ref_from_dict = FirstRef.model_validate(first_ref_dict) ``` [[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-aiohttp/docs/Foo.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Foo.md index f635b0daa6db..c11ae111ee22 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Foo.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Foo.md @@ -15,14 +15,14 @@ from petstore_api.models.foo import Foo # TODO update the JSON string below json = "{}" # create an instance of Foo from a JSON string -foo_instance = Foo.from_json(json) +foo_instance = Foo.model_validate_json(json) # print the JSON string representation of the object -print(Foo.to_json()) +print(foo_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -foo_dict = foo_instance.to_dict() +foo_dict = foo_instance.model_dump(by_alias=True) # create an instance of Foo from a dict -foo_from_dict = Foo.from_dict(foo_dict) +foo_from_dict = Foo.model_validate(foo_dict) ``` [[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-aiohttp/docs/FooGetDefaultResponse.md b/samples/openapi3/client/petstore/python-aiohttp/docs/FooGetDefaultResponse.md index 8d84f795b00a..aaccf08bfd2e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/FooGetDefaultResponse.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/FooGetDefaultResponse.md @@ -15,14 +15,14 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse # TODO update the JSON string below json = "{}" # create an instance of FooGetDefaultResponse from a JSON string -foo_get_default_response_instance = FooGetDefaultResponse.from_json(json) +foo_get_default_response_instance = FooGetDefaultResponse.model_validate_json(json) # print the JSON string representation of the object -print(FooGetDefaultResponse.to_json()) +print(foo_get_default_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -foo_get_default_response_dict = foo_get_default_response_instance.to_dict() +foo_get_default_response_dict = foo_get_default_response_instance.model_dump(by_alias=True) # create an instance of FooGetDefaultResponse from a dict -foo_get_default_response_from_dict = FooGetDefaultResponse.from_dict(foo_get_default_response_dict) +foo_get_default_response_from_dict = FooGetDefaultResponse.model_validate(foo_get_default_response_dict) ``` [[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-aiohttp/docs/FormatTest.md b/samples/openapi3/client/petstore/python-aiohttp/docs/FormatTest.md index 714d2401bbae..98c3dc89570d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/FormatTest.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/FormatTest.md @@ -31,14 +31,14 @@ from petstore_api.models.format_test import FormatTest # TODO update the JSON string below json = "{}" # create an instance of FormatTest from a JSON string -format_test_instance = FormatTest.from_json(json) +format_test_instance = FormatTest.model_validate_json(json) # print the JSON string representation of the object -print(FormatTest.to_json()) +print(format_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -format_test_dict = format_test_instance.to_dict() +format_test_dict = format_test_instance.model_dump(by_alias=True) # create an instance of FormatTest from a dict -format_test_from_dict = FormatTest.from_dict(format_test_dict) +format_test_from_dict = FormatTest.model_validate(format_test_dict) ``` [[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-aiohttp/docs/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/python-aiohttp/docs/HasOnlyReadOnly.md index fdc48781b15a..66dca11251aa 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/HasOnlyReadOnly.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/HasOnlyReadOnly.md @@ -16,14 +16,14 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly # TODO update the JSON string below json = "{}" # create an instance of HasOnlyReadOnly from a JSON string -has_only_read_only_instance = HasOnlyReadOnly.from_json(json) +has_only_read_only_instance = HasOnlyReadOnly.model_validate_json(json) # print the JSON string representation of the object -print(HasOnlyReadOnly.to_json()) +print(has_only_read_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -has_only_read_only_dict = has_only_read_only_instance.to_dict() +has_only_read_only_dict = has_only_read_only_instance.model_dump(by_alias=True) # create an instance of HasOnlyReadOnly from a dict -has_only_read_only_from_dict = HasOnlyReadOnly.from_dict(has_only_read_only_dict) +has_only_read_only_from_dict = HasOnlyReadOnly.model_validate(has_only_read_only_dict) ``` [[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-aiohttp/docs/HealthCheckResult.md b/samples/openapi3/client/petstore/python-aiohttp/docs/HealthCheckResult.md index d4a2b187167f..522156ae5b16 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/HealthCheckResult.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/HealthCheckResult.md @@ -16,14 +16,14 @@ from petstore_api.models.health_check_result import HealthCheckResult # TODO update the JSON string below json = "{}" # create an instance of HealthCheckResult from a JSON string -health_check_result_instance = HealthCheckResult.from_json(json) +health_check_result_instance = HealthCheckResult.model_validate_json(json) # print the JSON string representation of the object -print(HealthCheckResult.to_json()) +print(health_check_result_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -health_check_result_dict = health_check_result_instance.to_dict() +health_check_result_dict = health_check_result_instance.model_dump(by_alias=True) # create an instance of HealthCheckResult from a dict -health_check_result_from_dict = HealthCheckResult.from_dict(health_check_result_dict) +health_check_result_from_dict = HealthCheckResult.model_validate(health_check_result_dict) ``` [[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-aiohttp/docs/HuntingDog.md b/samples/openapi3/client/petstore/python-aiohttp/docs/HuntingDog.md index 6db6745dd022..114dfc8575d9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/HuntingDog.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/HuntingDog.md @@ -15,14 +15,14 @@ from petstore_api.models.hunting_dog import HuntingDog # TODO update the JSON string below json = "{}" # create an instance of HuntingDog from a JSON string -hunting_dog_instance = HuntingDog.from_json(json) +hunting_dog_instance = HuntingDog.model_validate_json(json) # print the JSON string representation of the object -print(HuntingDog.to_json()) +print(hunting_dog_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -hunting_dog_dict = hunting_dog_instance.to_dict() +hunting_dog_dict = hunting_dog_instance.model_dump(by_alias=True) # create an instance of HuntingDog from a dict -hunting_dog_from_dict = HuntingDog.from_dict(hunting_dog_dict) +hunting_dog_from_dict = HuntingDog.model_validate(hunting_dog_dict) ``` [[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-aiohttp/docs/Info.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Info.md index db88778a9143..160c3633247c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Info.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Info.md @@ -15,14 +15,14 @@ from petstore_api.models.info import Info # TODO update the JSON string below json = "{}" # create an instance of Info from a JSON string -info_instance = Info.from_json(json) +info_instance = Info.model_validate_json(json) # print the JSON string representation of the object -print(Info.to_json()) +print(info_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -info_dict = info_instance.to_dict() +info_dict = info_instance.model_dump(by_alias=True) # create an instance of Info from a dict -info_from_dict = Info.from_dict(info_dict) +info_from_dict = Info.model_validate(info_dict) ``` [[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-aiohttp/docs/InnerDictWithProperty.md b/samples/openapi3/client/petstore/python-aiohttp/docs/InnerDictWithProperty.md index 7b82ebb770b8..79234d754027 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/InnerDictWithProperty.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/InnerDictWithProperty.md @@ -15,14 +15,14 @@ from petstore_api.models.inner_dict_with_property import InnerDictWithProperty # TODO update the JSON string below json = "{}" # create an instance of InnerDictWithProperty from a JSON string -inner_dict_with_property_instance = InnerDictWithProperty.from_json(json) +inner_dict_with_property_instance = InnerDictWithProperty.model_validate_json(json) # print the JSON string representation of the object -print(InnerDictWithProperty.to_json()) +print(inner_dict_with_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -inner_dict_with_property_dict = inner_dict_with_property_instance.to_dict() +inner_dict_with_property_dict = inner_dict_with_property_instance.model_dump(by_alias=True) # create an instance of InnerDictWithProperty from a dict -inner_dict_with_property_from_dict = InnerDictWithProperty.from_dict(inner_dict_with_property_dict) +inner_dict_with_property_from_dict = InnerDictWithProperty.model_validate(inner_dict_with_property_dict) ``` [[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-aiohttp/docs/InputAllOf.md b/samples/openapi3/client/petstore/python-aiohttp/docs/InputAllOf.md index 45298f5308fc..32d4100ac9de 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/InputAllOf.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/InputAllOf.md @@ -15,14 +15,14 @@ from petstore_api.models.input_all_of import InputAllOf # TODO update the JSON string below json = "{}" # create an instance of InputAllOf from a JSON string -input_all_of_instance = InputAllOf.from_json(json) +input_all_of_instance = InputAllOf.model_validate_json(json) # print the JSON string representation of the object -print(InputAllOf.to_json()) +print(input_all_of_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -input_all_of_dict = input_all_of_instance.to_dict() +input_all_of_dict = input_all_of_instance.model_dump(by_alias=True) # create an instance of InputAllOf from a dict -input_all_of_from_dict = InputAllOf.from_dict(input_all_of_dict) +input_all_of_from_dict = InputAllOf.model_validate(input_all_of_dict) ``` [[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-aiohttp/docs/IntOrString.md b/samples/openapi3/client/petstore/python-aiohttp/docs/IntOrString.md index b4070b9a8c79..ea8e06339493 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/IntOrString.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/IntOrString.md @@ -14,14 +14,14 @@ from petstore_api.models.int_or_string import IntOrString # TODO update the JSON string below json = "{}" # create an instance of IntOrString from a JSON string -int_or_string_instance = IntOrString.from_json(json) +int_or_string_instance = IntOrString.model_validate_json(json) # print the JSON string representation of the object -print(IntOrString.to_json()) +print(int_or_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -int_or_string_dict = int_or_string_instance.to_dict() +int_or_string_dict = int_or_string_instance.model_dump(by_alias=True) # create an instance of IntOrString from a dict -int_or_string_from_dict = IntOrString.from_dict(int_or_string_dict) +int_or_string_from_dict = IntOrString.model_validate(int_or_string_dict) ``` [[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-aiohttp/docs/ListClass.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ListClass.md index 01068b7d22c3..8bc905105efe 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ListClass.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ListClass.md @@ -15,14 +15,14 @@ from petstore_api.models.list_class import ListClass # TODO update the JSON string below json = "{}" # create an instance of ListClass from a JSON string -list_class_instance = ListClass.from_json(json) +list_class_instance = ListClass.model_validate_json(json) # print the JSON string representation of the object -print(ListClass.to_json()) +print(list_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -list_class_dict = list_class_instance.to_dict() +list_class_dict = list_class_instance.model_dump(by_alias=True) # create an instance of ListClass from a dict -list_class_from_dict = ListClass.from_dict(list_class_dict) +list_class_from_dict = ListClass.model_validate(list_class_dict) ``` [[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-aiohttp/docs/MapOfArrayOfModel.md b/samples/openapi3/client/petstore/python-aiohttp/docs/MapOfArrayOfModel.md index 71a4ef66b682..acea13d9a9f5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/MapOfArrayOfModel.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/MapOfArrayOfModel.md @@ -15,14 +15,14 @@ from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel # TODO update the JSON string below json = "{}" # create an instance of MapOfArrayOfModel from a JSON string -map_of_array_of_model_instance = MapOfArrayOfModel.from_json(json) +map_of_array_of_model_instance = MapOfArrayOfModel.model_validate_json(json) # print the JSON string representation of the object -print(MapOfArrayOfModel.to_json()) +print(map_of_array_of_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -map_of_array_of_model_dict = map_of_array_of_model_instance.to_dict() +map_of_array_of_model_dict = map_of_array_of_model_instance.model_dump(by_alias=True) # create an instance of MapOfArrayOfModel from a dict -map_of_array_of_model_from_dict = MapOfArrayOfModel.from_dict(map_of_array_of_model_dict) +map_of_array_of_model_from_dict = MapOfArrayOfModel.model_validate(map_of_array_of_model_dict) ``` [[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-aiohttp/docs/MapTest.md b/samples/openapi3/client/petstore/python-aiohttp/docs/MapTest.md index d04b82e9378c..fa4501d24286 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/MapTest.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/MapTest.md @@ -18,14 +18,14 @@ from petstore_api.models.map_test import MapTest # TODO update the JSON string below json = "{}" # create an instance of MapTest from a JSON string -map_test_instance = MapTest.from_json(json) +map_test_instance = MapTest.model_validate_json(json) # print the JSON string representation of the object -print(MapTest.to_json()) +print(map_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -map_test_dict = map_test_instance.to_dict() +map_test_dict = map_test_instance.model_dump(by_alias=True) # create an instance of MapTest from a dict -map_test_from_dict = MapTest.from_dict(map_test_dict) +map_test_from_dict = MapTest.model_validate(map_test_dict) ``` [[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-aiohttp/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-aiohttp/docs/MixedPropertiesAndAdditionalPropertiesClass.md index 84134317aefc..fb354956720a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -17,14 +17,14 @@ from petstore_api.models.mixed_properties_and_additional_properties_class import # TODO update the JSON string below json = "{}" # create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string -mixed_properties_and_additional_properties_class_instance = MixedPropertiesAndAdditionalPropertiesClass.from_json(json) +mixed_properties_and_additional_properties_class_instance = MixedPropertiesAndAdditionalPropertiesClass.model_validate_json(json) # print the JSON string representation of the object -print(MixedPropertiesAndAdditionalPropertiesClass.to_json()) +print(mixed_properties_and_additional_properties_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -mixed_properties_and_additional_properties_class_dict = mixed_properties_and_additional_properties_class_instance.to_dict() +mixed_properties_and_additional_properties_class_dict = mixed_properties_and_additional_properties_class_instance.model_dump(by_alias=True) # create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict -mixed_properties_and_additional_properties_class_from_dict = MixedPropertiesAndAdditionalPropertiesClass.from_dict(mixed_properties_and_additional_properties_class_dict) +mixed_properties_and_additional_properties_class_from_dict = MixedPropertiesAndAdditionalPropertiesClass.model_validate(mixed_properties_and_additional_properties_class_dict) ``` [[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-aiohttp/docs/Model200Response.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Model200Response.md index 7fdbdefc6cec..6cffad7a6d3a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Model200Response.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Model200Response.md @@ -17,14 +17,14 @@ from petstore_api.models.model200_response import Model200Response # TODO update the JSON string below json = "{}" # create an instance of Model200Response from a JSON string -model200_response_instance = Model200Response.from_json(json) +model200_response_instance = Model200Response.model_validate_json(json) # print the JSON string representation of the object -print(Model200Response.to_json()) +print(model200_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model200_response_dict = model200_response_instance.to_dict() +model200_response_dict = model200_response_instance.model_dump(by_alias=True) # create an instance of Model200Response from a dict -model200_response_from_dict = Model200Response.from_dict(model200_response_dict) +model200_response_from_dict = Model200Response.model_validate(model200_response_dict) ``` [[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-aiohttp/docs/ModelApiResponse.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ModelApiResponse.md index 5ddc0db2a0f3..4fdaa910bce4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ModelApiResponse.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ModelApiResponse.md @@ -17,14 +17,14 @@ from petstore_api.models.model_api_response import ModelApiResponse # TODO update the JSON string below json = "{}" # create an instance of ModelApiResponse from a JSON string -model_api_response_instance = ModelApiResponse.from_json(json) +model_api_response_instance = ModelApiResponse.model_validate_json(json) # print the JSON string representation of the object -print(ModelApiResponse.to_json()) +print(model_api_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_api_response_dict = model_api_response_instance.to_dict() +model_api_response_dict = model_api_response_instance.model_dump(by_alias=True) # create an instance of ModelApiResponse from a dict -model_api_response_from_dict = ModelApiResponse.from_dict(model_api_response_dict) +model_api_response_from_dict = ModelApiResponse.model_validate(model_api_response_dict) ``` [[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-aiohttp/docs/ModelField.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ModelField.md index 9073b5dbdb00..43f064bd85a4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ModelField.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ModelField.md @@ -15,14 +15,14 @@ from petstore_api.models.model_field import ModelField # TODO update the JSON string below json = "{}" # create an instance of ModelField from a JSON string -model_field_instance = ModelField.from_json(json) +model_field_instance = ModelField.model_validate_json(json) # print the JSON string representation of the object -print(ModelField.to_json()) +print(model_field_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_field_dict = model_field_instance.to_dict() +model_field_dict = model_field_instance.model_dump(by_alias=True) # create an instance of ModelField from a dict -model_field_from_dict = ModelField.from_dict(model_field_dict) +model_field_from_dict = ModelField.model_validate(model_field_dict) ``` [[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-aiohttp/docs/ModelReturn.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ModelReturn.md index 7d327053b0c3..236b2bb971ee 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ModelReturn.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ModelReturn.md @@ -16,14 +16,14 @@ from petstore_api.models.model_return import ModelReturn # TODO update the JSON string below json = "{}" # create an instance of ModelReturn from a JSON string -model_return_instance = ModelReturn.from_json(json) +model_return_instance = ModelReturn.model_validate_json(json) # print the JSON string representation of the object -print(ModelReturn.to_json()) +print(model_return_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_return_dict = model_return_instance.to_dict() +model_return_dict = model_return_instance.model_dump(by_alias=True) # create an instance of ModelReturn from a dict -model_return_from_dict = ModelReturn.from_dict(model_return_dict) +model_return_from_dict = ModelReturn.model_validate(model_return_dict) ``` [[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-aiohttp/docs/MultiArrays.md b/samples/openapi3/client/petstore/python-aiohttp/docs/MultiArrays.md index fea5139e7e73..9cf5c5bb1faa 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/MultiArrays.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/MultiArrays.md @@ -16,14 +16,14 @@ from petstore_api.models.multi_arrays import MultiArrays # TODO update the JSON string below json = "{}" # create an instance of MultiArrays from a JSON string -multi_arrays_instance = MultiArrays.from_json(json) +multi_arrays_instance = MultiArrays.model_validate_json(json) # print the JSON string representation of the object -print(MultiArrays.to_json()) +print(multi_arrays_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -multi_arrays_dict = multi_arrays_instance.to_dict() +multi_arrays_dict = multi_arrays_instance.model_dump(by_alias=True) # create an instance of MultiArrays from a dict -multi_arrays_from_dict = MultiArrays.from_dict(multi_arrays_dict) +multi_arrays_from_dict = MultiArrays.model_validate(multi_arrays_dict) ``` [[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-aiohttp/docs/Name.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Name.md index 5a04ec1ada06..f9d2da4cccd2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Name.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Name.md @@ -19,14 +19,14 @@ from petstore_api.models.name import Name # TODO update the JSON string below json = "{}" # create an instance of Name from a JSON string -name_instance = Name.from_json(json) +name_instance = Name.model_validate_json(json) # print the JSON string representation of the object -print(Name.to_json()) +print(name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -name_dict = name_instance.to_dict() +name_dict = name_instance.model_dump(by_alias=True) # create an instance of Name from a dict -name_from_dict = Name.from_dict(name_dict) +name_from_dict = Name.model_validate(name_dict) ``` [[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-aiohttp/docs/NullableClass.md b/samples/openapi3/client/petstore/python-aiohttp/docs/NullableClass.md index 0387dcc2c67a..cd84aa96eb19 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/NullableClass.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/NullableClass.md @@ -27,14 +27,14 @@ from petstore_api.models.nullable_class import NullableClass # TODO update the JSON string below json = "{}" # create an instance of NullableClass from a JSON string -nullable_class_instance = NullableClass.from_json(json) +nullable_class_instance = NullableClass.model_validate_json(json) # print the JSON string representation of the object -print(NullableClass.to_json()) +print(nullable_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -nullable_class_dict = nullable_class_instance.to_dict() +nullable_class_dict = nullable_class_instance.model_dump(by_alias=True) # create an instance of NullableClass from a dict -nullable_class_from_dict = NullableClass.from_dict(nullable_class_dict) +nullable_class_from_dict = NullableClass.model_validate(nullable_class_dict) ``` [[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-aiohttp/docs/NullableProperty.md b/samples/openapi3/client/petstore/python-aiohttp/docs/NullableProperty.md index 30edaf4844b2..c0ef9b80fcb5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/NullableProperty.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/NullableProperty.md @@ -16,14 +16,14 @@ from petstore_api.models.nullable_property import NullableProperty # TODO update the JSON string below json = "{}" # create an instance of NullableProperty from a JSON string -nullable_property_instance = NullableProperty.from_json(json) +nullable_property_instance = NullableProperty.model_validate_json(json) # print the JSON string representation of the object -print(NullableProperty.to_json()) +print(nullable_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -nullable_property_dict = nullable_property_instance.to_dict() +nullable_property_dict = nullable_property_instance.model_dump(by_alias=True) # create an instance of NullableProperty from a dict -nullable_property_from_dict = NullableProperty.from_dict(nullable_property_dict) +nullable_property_from_dict = NullableProperty.model_validate(nullable_property_dict) ``` [[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-aiohttp/docs/NumberOnly.md b/samples/openapi3/client/petstore/python-aiohttp/docs/NumberOnly.md index 415dd25585d4..f1caf70ea2b7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/NumberOnly.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/NumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.number_only import NumberOnly # TODO update the JSON string below json = "{}" # create an instance of NumberOnly from a JSON string -number_only_instance = NumberOnly.from_json(json) +number_only_instance = NumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(NumberOnly.to_json()) +print(number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -number_only_dict = number_only_instance.to_dict() +number_only_dict = number_only_instance.model_dump(by_alias=True) # create an instance of NumberOnly from a dict -number_only_from_dict = NumberOnly.from_dict(number_only_dict) +number_only_from_dict = NumberOnly.model_validate(number_only_dict) ``` [[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-aiohttp/docs/ObjectToTestAdditionalProperties.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ObjectToTestAdditionalProperties.md index f6bc34c98e65..f201a9627dc3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ObjectToTestAdditionalProperties.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ObjectToTestAdditionalProperties.md @@ -16,14 +16,14 @@ from petstore_api.models.object_to_test_additional_properties import ObjectToTes # TODO update the JSON string below json = "{}" # create an instance of ObjectToTestAdditionalProperties from a JSON string -object_to_test_additional_properties_instance = ObjectToTestAdditionalProperties.from_json(json) +object_to_test_additional_properties_instance = ObjectToTestAdditionalProperties.model_validate_json(json) # print the JSON string representation of the object -print(ObjectToTestAdditionalProperties.to_json()) +print(object_to_test_additional_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -object_to_test_additional_properties_dict = object_to_test_additional_properties_instance.to_dict() +object_to_test_additional_properties_dict = object_to_test_additional_properties_instance.model_dump(by_alias=True) # create an instance of ObjectToTestAdditionalProperties from a dict -object_to_test_additional_properties_from_dict = ObjectToTestAdditionalProperties.from_dict(object_to_test_additional_properties_dict) +object_to_test_additional_properties_from_dict = ObjectToTestAdditionalProperties.model_validate(object_to_test_additional_properties_dict) ``` [[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-aiohttp/docs/ObjectWithDeprecatedFields.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ObjectWithDeprecatedFields.md index 6dbd2ace04f1..86cce93ba775 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ObjectWithDeprecatedFields.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ObjectWithDeprecatedFields.md @@ -18,14 +18,14 @@ from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecat # TODO update the JSON string below json = "{}" # create an instance of ObjectWithDeprecatedFields from a JSON string -object_with_deprecated_fields_instance = ObjectWithDeprecatedFields.from_json(json) +object_with_deprecated_fields_instance = ObjectWithDeprecatedFields.model_validate_json(json) # print the JSON string representation of the object -print(ObjectWithDeprecatedFields.to_json()) +print(object_with_deprecated_fields_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -object_with_deprecated_fields_dict = object_with_deprecated_fields_instance.to_dict() +object_with_deprecated_fields_dict = object_with_deprecated_fields_instance.model_dump(by_alias=True) # create an instance of ObjectWithDeprecatedFields from a dict -object_with_deprecated_fields_from_dict = ObjectWithDeprecatedFields.from_dict(object_with_deprecated_fields_dict) +object_with_deprecated_fields_from_dict = ObjectWithDeprecatedFields.model_validate(object_with_deprecated_fields_dict) ``` [[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-aiohttp/docs/Order.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Order.md index 00526b8d04b9..f5410bc8d0f3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Order.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Order.md @@ -20,14 +20,14 @@ from petstore_api.models.order import Order # TODO update the JSON string below json = "{}" # create an instance of Order from a JSON string -order_instance = Order.from_json(json) +order_instance = Order.model_validate_json(json) # print the JSON string representation of the object -print(Order.to_json()) +print(order_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -order_dict = order_instance.to_dict() +order_dict = order_instance.model_dump(by_alias=True) # create an instance of Order from a dict -order_from_dict = Order.from_dict(order_dict) +order_from_dict = Order.model_validate(order_dict) ``` [[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-aiohttp/docs/OuterComposite.md b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterComposite.md index c8242c2d2653..9df82e2abc87 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterComposite.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterComposite.md @@ -17,14 +17,14 @@ from petstore_api.models.outer_composite import OuterComposite # TODO update the JSON string below json = "{}" # create an instance of OuterComposite from a JSON string -outer_composite_instance = OuterComposite.from_json(json) +outer_composite_instance = OuterComposite.model_validate_json(json) # print the JSON string representation of the object -print(OuterComposite.to_json()) +print(outer_composite_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -outer_composite_dict = outer_composite_instance.to_dict() +outer_composite_dict = outer_composite_instance.model_dump(by_alias=True) # create an instance of OuterComposite from a dict -outer_composite_from_dict = OuterComposite.from_dict(outer_composite_dict) +outer_composite_from_dict = OuterComposite.model_validate(outer_composite_dict) ``` [[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-aiohttp/docs/OuterObjectWithEnumProperty.md b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterObjectWithEnumProperty.md index 6137dbd98da6..d23ccc3757bb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/OuterObjectWithEnumProperty.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/OuterObjectWithEnumProperty.md @@ -16,14 +16,14 @@ from petstore_api.models.outer_object_with_enum_property import OuterObjectWithE # TODO update the JSON string below json = "{}" # create an instance of OuterObjectWithEnumProperty from a JSON string -outer_object_with_enum_property_instance = OuterObjectWithEnumProperty.from_json(json) +outer_object_with_enum_property_instance = OuterObjectWithEnumProperty.model_validate_json(json) # print the JSON string representation of the object -print(OuterObjectWithEnumProperty.to_json()) +print(outer_object_with_enum_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -outer_object_with_enum_property_dict = outer_object_with_enum_property_instance.to_dict() +outer_object_with_enum_property_dict = outer_object_with_enum_property_instance.model_dump(by_alias=True) # create an instance of OuterObjectWithEnumProperty from a dict -outer_object_with_enum_property_from_dict = OuterObjectWithEnumProperty.from_dict(outer_object_with_enum_property_dict) +outer_object_with_enum_property_from_dict = OuterObjectWithEnumProperty.model_validate(outer_object_with_enum_property_dict) ``` [[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-aiohttp/docs/Parent.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Parent.md index 7387f9250aad..21df089ea756 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Parent.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Parent.md @@ -15,14 +15,14 @@ from petstore_api.models.parent import Parent # TODO update the JSON string below json = "{}" # create an instance of Parent from a JSON string -parent_instance = Parent.from_json(json) +parent_instance = Parent.model_validate_json(json) # print the JSON string representation of the object -print(Parent.to_json()) +print(parent_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -parent_dict = parent_instance.to_dict() +parent_dict = parent_instance.model_dump(by_alias=True) # create an instance of Parent from a dict -parent_from_dict = Parent.from_dict(parent_dict) +parent_from_dict = Parent.model_validate(parent_dict) ``` [[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-aiohttp/docs/ParentWithOptionalDict.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ParentWithOptionalDict.md index bfc8688ea26f..a6ee19fd1a74 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ParentWithOptionalDict.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ParentWithOptionalDict.md @@ -15,14 +15,14 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict # TODO update the JSON string below json = "{}" # create an instance of ParentWithOptionalDict from a JSON string -parent_with_optional_dict_instance = ParentWithOptionalDict.from_json(json) +parent_with_optional_dict_instance = ParentWithOptionalDict.model_validate_json(json) # print the JSON string representation of the object -print(ParentWithOptionalDict.to_json()) +print(parent_with_optional_dict_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -parent_with_optional_dict_dict = parent_with_optional_dict_instance.to_dict() +parent_with_optional_dict_dict = parent_with_optional_dict_instance.model_dump(by_alias=True) # create an instance of ParentWithOptionalDict from a dict -parent_with_optional_dict_from_dict = ParentWithOptionalDict.from_dict(parent_with_optional_dict_dict) +parent_with_optional_dict_from_dict = ParentWithOptionalDict.model_validate(parent_with_optional_dict_dict) ``` [[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-aiohttp/docs/Pet.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Pet.md index 5329cf2fb925..179b71891d9d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Pet.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Pet.md @@ -20,14 +20,14 @@ from petstore_api.models.pet import Pet # TODO update the JSON string below json = "{}" # create an instance of Pet from a JSON string -pet_instance = Pet.from_json(json) +pet_instance = Pet.model_validate_json(json) # print the JSON string representation of the object -print(Pet.to_json()) +print(pet_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pet_dict = pet_instance.to_dict() +pet_dict = pet_instance.model_dump(by_alias=True) # create an instance of Pet from a dict -pet_from_dict = Pet.from_dict(pet_dict) +pet_from_dict = Pet.model_validate(pet_dict) ``` [[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-aiohttp/docs/Pig.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Pig.md index 625930676083..2e275198c547 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Pig.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Pig.md @@ -17,14 +17,14 @@ from petstore_api.models.pig import Pig # TODO update the JSON string below json = "{}" # create an instance of Pig from a JSON string -pig_instance = Pig.from_json(json) +pig_instance = Pig.model_validate_json(json) # print the JSON string representation of the object -print(Pig.to_json()) +print(pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pig_dict = pig_instance.to_dict() +pig_dict = pig_instance.model_dump(by_alias=True) # create an instance of Pig from a dict -pig_from_dict = Pig.from_dict(pig_dict) +pig_from_dict = Pig.model_validate(pig_dict) ``` [[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-aiohttp/docs/PonySizes.md b/samples/openapi3/client/petstore/python-aiohttp/docs/PonySizes.md index ced44c872060..6bb28b418b6d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/PonySizes.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/PonySizes.md @@ -15,14 +15,14 @@ from petstore_api.models.pony_sizes import PonySizes # TODO update the JSON string below json = "{}" # create an instance of PonySizes from a JSON string -pony_sizes_instance = PonySizes.from_json(json) +pony_sizes_instance = PonySizes.model_validate_json(json) # print the JSON string representation of the object -print(PonySizes.to_json()) +print(pony_sizes_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pony_sizes_dict = pony_sizes_instance.to_dict() +pony_sizes_dict = pony_sizes_instance.model_dump(by_alias=True) # create an instance of PonySizes from a dict -pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_dict) +pony_sizes_from_dict = PonySizes.model_validate(pony_sizes_dict) ``` [[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-aiohttp/docs/PoopCleaning.md b/samples/openapi3/client/petstore/python-aiohttp/docs/PoopCleaning.md index 8f9c25e08316..3bf20593f929 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/PoopCleaning.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/PoopCleaning.md @@ -17,14 +17,14 @@ from petstore_api.models.poop_cleaning import PoopCleaning # TODO update the JSON string below json = "{}" # create an instance of PoopCleaning from a JSON string -poop_cleaning_instance = PoopCleaning.from_json(json) +poop_cleaning_instance = PoopCleaning.model_validate_json(json) # print the JSON string representation of the object -print(PoopCleaning.to_json()) +print(poop_cleaning_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -poop_cleaning_dict = poop_cleaning_instance.to_dict() +poop_cleaning_dict = poop_cleaning_instance.model_dump(by_alias=True) # create an instance of PoopCleaning from a dict -poop_cleaning_from_dict = PoopCleaning.from_dict(poop_cleaning_dict) +poop_cleaning_from_dict = PoopCleaning.model_validate(poop_cleaning_dict) ``` [[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-aiohttp/docs/PrimitiveString.md b/samples/openapi3/client/petstore/python-aiohttp/docs/PrimitiveString.md index 85ceb632e167..a1a9a3dc81b6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/PrimitiveString.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/PrimitiveString.md @@ -15,14 +15,14 @@ from petstore_api.models.primitive_string import PrimitiveString # TODO update the JSON string below json = "{}" # create an instance of PrimitiveString from a JSON string -primitive_string_instance = PrimitiveString.from_json(json) +primitive_string_instance = PrimitiveString.model_validate_json(json) # print the JSON string representation of the object -print(PrimitiveString.to_json()) +print(primitive_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -primitive_string_dict = primitive_string_instance.to_dict() +primitive_string_dict = primitive_string_instance.model_dump(by_alias=True) # create an instance of PrimitiveString from a dict -primitive_string_from_dict = PrimitiveString.from_dict(primitive_string_dict) +primitive_string_from_dict = PrimitiveString.model_validate(primitive_string_dict) ``` [[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-aiohttp/docs/PropertyMap.md b/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyMap.md index a55a0e5c6f01..5fcda1f7803d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyMap.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyMap.md @@ -15,14 +15,14 @@ from petstore_api.models.property_map import PropertyMap # TODO update the JSON string below json = "{}" # create an instance of PropertyMap from a JSON string -property_map_instance = PropertyMap.from_json(json) +property_map_instance = PropertyMap.model_validate_json(json) # print the JSON string representation of the object -print(PropertyMap.to_json()) +print(property_map_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -property_map_dict = property_map_instance.to_dict() +property_map_dict = property_map_instance.model_dump(by_alias=True) # create an instance of PropertyMap from a dict -property_map_from_dict = PropertyMap.from_dict(property_map_dict) +property_map_from_dict = PropertyMap.model_validate(property_map_dict) ``` [[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-aiohttp/docs/PropertyNameCollision.md b/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyNameCollision.md index 40c233670dd0..a4a8405fe847 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyNameCollision.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/PropertyNameCollision.md @@ -17,14 +17,14 @@ from petstore_api.models.property_name_collision import PropertyNameCollision # TODO update the JSON string below json = "{}" # create an instance of PropertyNameCollision from a JSON string -property_name_collision_instance = PropertyNameCollision.from_json(json) +property_name_collision_instance = PropertyNameCollision.model_validate_json(json) # print the JSON string representation of the object -print(PropertyNameCollision.to_json()) +print(property_name_collision_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -property_name_collision_dict = property_name_collision_instance.to_dict() +property_name_collision_dict = property_name_collision_instance.model_dump(by_alias=True) # create an instance of PropertyNameCollision from a dict -property_name_collision_from_dict = PropertyNameCollision.from_dict(property_name_collision_dict) +property_name_collision_from_dict = PropertyNameCollision.model_validate(property_name_collision_dict) ``` [[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-aiohttp/docs/ReadOnlyFirst.md b/samples/openapi3/client/petstore/python-aiohttp/docs/ReadOnlyFirst.md index 686ec5da41c9..e55fe102b673 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/ReadOnlyFirst.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/ReadOnlyFirst.md @@ -16,14 +16,14 @@ from petstore_api.models.read_only_first import ReadOnlyFirst # TODO update the JSON string below json = "{}" # create an instance of ReadOnlyFirst from a JSON string -read_only_first_instance = ReadOnlyFirst.from_json(json) +read_only_first_instance = ReadOnlyFirst.model_validate_json(json) # print the JSON string representation of the object -print(ReadOnlyFirst.to_json()) +print(read_only_first_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -read_only_first_dict = read_only_first_instance.to_dict() +read_only_first_dict = read_only_first_instance.model_dump(by_alias=True) # create an instance of ReadOnlyFirst from a dict -read_only_first_from_dict = ReadOnlyFirst.from_dict(read_only_first_dict) +read_only_first_from_dict = ReadOnlyFirst.model_validate(read_only_first_dict) ``` [[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-aiohttp/docs/SecondCircularAllOfRef.md b/samples/openapi3/client/petstore/python-aiohttp/docs/SecondCircularAllOfRef.md index 65ebdd4c7e1d..47fb4daf97a4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/SecondCircularAllOfRef.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/SecondCircularAllOfRef.md @@ -16,14 +16,14 @@ from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRe # TODO update the JSON string below json = "{}" # create an instance of SecondCircularAllOfRef from a JSON string -second_circular_all_of_ref_instance = SecondCircularAllOfRef.from_json(json) +second_circular_all_of_ref_instance = SecondCircularAllOfRef.model_validate_json(json) # print the JSON string representation of the object -print(SecondCircularAllOfRef.to_json()) +print(second_circular_all_of_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -second_circular_all_of_ref_dict = second_circular_all_of_ref_instance.to_dict() +second_circular_all_of_ref_dict = second_circular_all_of_ref_instance.model_dump(by_alias=True) # create an instance of SecondCircularAllOfRef from a dict -second_circular_all_of_ref_from_dict = SecondCircularAllOfRef.from_dict(second_circular_all_of_ref_dict) +second_circular_all_of_ref_from_dict = SecondCircularAllOfRef.model_validate(second_circular_all_of_ref_dict) ``` [[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-aiohttp/docs/SecondRef.md b/samples/openapi3/client/petstore/python-aiohttp/docs/SecondRef.md index dfb1a0ac6db5..fa0b9f285e0c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/SecondRef.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/SecondRef.md @@ -16,14 +16,14 @@ from petstore_api.models.second_ref import SecondRef # TODO update the JSON string below json = "{}" # create an instance of SecondRef from a JSON string -second_ref_instance = SecondRef.from_json(json) +second_ref_instance = SecondRef.model_validate_json(json) # print the JSON string representation of the object -print(SecondRef.to_json()) +print(second_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -second_ref_dict = second_ref_instance.to_dict() +second_ref_dict = second_ref_instance.model_dump(by_alias=True) # create an instance of SecondRef from a dict -second_ref_from_dict = SecondRef.from_dict(second_ref_dict) +second_ref_from_dict = SecondRef.model_validate(second_ref_dict) ``` [[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-aiohttp/docs/SelfReferenceModel.md b/samples/openapi3/client/petstore/python-aiohttp/docs/SelfReferenceModel.md index 208cdac04b6f..af3c77d0524b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/SelfReferenceModel.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/SelfReferenceModel.md @@ -16,14 +16,14 @@ from petstore_api.models.self_reference_model import SelfReferenceModel # TODO update the JSON string below json = "{}" # create an instance of SelfReferenceModel from a JSON string -self_reference_model_instance = SelfReferenceModel.from_json(json) +self_reference_model_instance = SelfReferenceModel.model_validate_json(json) # print the JSON string representation of the object -print(SelfReferenceModel.to_json()) +print(self_reference_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -self_reference_model_dict = self_reference_model_instance.to_dict() +self_reference_model_dict = self_reference_model_instance.model_dump(by_alias=True) # create an instance of SelfReferenceModel from a dict -self_reference_model_from_dict = SelfReferenceModel.from_dict(self_reference_model_dict) +self_reference_model_from_dict = SelfReferenceModel.model_validate(self_reference_model_dict) ``` [[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-aiohttp/docs/SpecialModelName.md b/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialModelName.md index 35303f34efd2..589dbeb14b94 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialModelName.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialModelName.md @@ -15,14 +15,14 @@ from petstore_api.models.special_model_name import SpecialModelName # TODO update the JSON string below json = "{}" # create an instance of SpecialModelName from a JSON string -special_model_name_instance = SpecialModelName.from_json(json) +special_model_name_instance = SpecialModelName.model_validate_json(json) # print the JSON string representation of the object -print(SpecialModelName.to_json()) +print(special_model_name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -special_model_name_dict = special_model_name_instance.to_dict() +special_model_name_dict = special_model_name_instance.model_dump(by_alias=True) # create an instance of SpecialModelName from a dict -special_model_name_from_dict = SpecialModelName.from_dict(special_model_name_dict) +special_model_name_from_dict = SpecialModelName.model_validate(special_model_name_dict) ``` [[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-aiohttp/docs/SpecialName.md b/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialName.md index ccc550b16e33..19da9016451c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialName.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/SpecialName.md @@ -17,14 +17,14 @@ from petstore_api.models.special_name import SpecialName # TODO update the JSON string below json = "{}" # create an instance of SpecialName from a JSON string -special_name_instance = SpecialName.from_json(json) +special_name_instance = SpecialName.model_validate_json(json) # print the JSON string representation of the object -print(SpecialName.to_json()) +print(special_name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -special_name_dict = special_name_instance.to_dict() +special_name_dict = special_name_instance.model_dump(by_alias=True) # create an instance of SpecialName from a dict -special_name_from_dict = SpecialName.from_dict(special_name_dict) +special_name_from_dict = SpecialName.model_validate(special_name_dict) ``` [[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-aiohttp/docs/Tag.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Tag.md index 4106d9cfe5db..66339d14c875 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Tag.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Tag.md @@ -16,14 +16,14 @@ from petstore_api.models.tag import Tag # TODO update the JSON string below json = "{}" # create an instance of Tag from a JSON string -tag_instance = Tag.from_json(json) +tag_instance = Tag.model_validate_json(json) # print the JSON string representation of the object -print(Tag.to_json()) +print(tag_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tag_dict = tag_instance.to_dict() +tag_dict = tag_instance.model_dump(by_alias=True) # create an instance of Tag from a dict -tag_from_dict = Tag.from_dict(tag_dict) +tag_from_dict = Tag.model_validate(tag_dict) ``` [[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-aiohttp/docs/Task.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Task.md index 85fa2776a059..229ed6510a11 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Task.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Task.md @@ -17,14 +17,14 @@ from petstore_api.models.task import Task # TODO update the JSON string below json = "{}" # create an instance of Task from a JSON string -task_instance = Task.from_json(json) +task_instance = Task.model_validate_json(json) # print the JSON string representation of the object -print(Task.to_json()) +print(task_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -task_dict = task_instance.to_dict() +task_dict = task_instance.model_dump(by_alias=True) # create an instance of Task from a dict -task_from_dict = Task.from_dict(task_dict) +task_from_dict = Task.model_validate(task_dict) ``` [[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-aiohttp/docs/TaskActivity.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TaskActivity.md index e905a477292d..c025d32ba436 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/TaskActivity.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TaskActivity.md @@ -17,14 +17,14 @@ from petstore_api.models.task_activity import TaskActivity # TODO update the JSON string below json = "{}" # create an instance of TaskActivity from a JSON string -task_activity_instance = TaskActivity.from_json(json) +task_activity_instance = TaskActivity.model_validate_json(json) # print the JSON string representation of the object -print(TaskActivity.to_json()) +print(task_activity_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -task_activity_dict = task_activity_instance.to_dict() +task_activity_dict = task_activity_instance.model_dump(by_alias=True) # create an instance of TaskActivity from a dict -task_activity_from_dict = TaskActivity.from_dict(task_activity_dict) +task_activity_from_dict = TaskActivity.model_validate(task_activity_dict) ``` [[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-aiohttp/docs/TestErrorResponsesWithModel400Response.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel400Response.md index be416bbad0f7..fed06705b55b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel400Response.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel400Response.md @@ -15,14 +15,14 @@ from petstore_api.models.test_error_responses_with_model400_response import Test # TODO update the JSON string below json = "{}" # create an instance of TestErrorResponsesWithModel400Response from a JSON string -test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.from_json(json) +test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.model_validate_json(json) # print the JSON string representation of the object -print(TestErrorResponsesWithModel400Response.to_json()) +print(test_error_responses_with_model400_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.to_dict() +test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.model_dump(by_alias=True) # create an instance of TestErrorResponsesWithModel400Response from a dict -test_error_responses_with_model400_response_from_dict = TestErrorResponsesWithModel400Response.from_dict(test_error_responses_with_model400_response_dict) +test_error_responses_with_model400_response_from_dict = TestErrorResponsesWithModel400Response.model_validate(test_error_responses_with_model400_response_dict) ``` [[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-aiohttp/docs/TestErrorResponsesWithModel404Response.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel404Response.md index 1c984f847bf1..8813e0792d22 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel404Response.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel404Response.md @@ -15,14 +15,14 @@ from petstore_api.models.test_error_responses_with_model404_response import Test # TODO update the JSON string below json = "{}" # create an instance of TestErrorResponsesWithModel404Response from a JSON string -test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.from_json(json) +test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.model_validate_json(json) # print the JSON string representation of the object -print(TestErrorResponsesWithModel404Response.to_json()) +print(test_error_responses_with_model404_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.to_dict() +test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.model_dump(by_alias=True) # create an instance of TestErrorResponsesWithModel404Response from a dict -test_error_responses_with_model404_response_from_dict = TestErrorResponsesWithModel404Response.from_dict(test_error_responses_with_model404_response_dict) +test_error_responses_with_model404_response_from_dict = TestErrorResponsesWithModel404Response.model_validate(test_error_responses_with_model404_response_dict) ``` [[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-aiohttp/docs/TestInlineFreeformAdditionalPropertiesRequest.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestInlineFreeformAdditionalPropertiesRequest.md index 511132d689be..870cd8850e6b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/TestInlineFreeformAdditionalPropertiesRequest.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestInlineFreeformAdditionalPropertiesRequest.md @@ -15,14 +15,14 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo # TODO update the JSON string below json = "{}" # create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string -test_inline_freeform_additional_properties_request_instance = TestInlineFreeformAdditionalPropertiesRequest.from_json(json) +test_inline_freeform_additional_properties_request_instance = TestInlineFreeformAdditionalPropertiesRequest.model_validate_json(json) # print the JSON string representation of the object -print(TestInlineFreeformAdditionalPropertiesRequest.to_json()) +print(test_inline_freeform_additional_properties_request_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_inline_freeform_additional_properties_request_dict = test_inline_freeform_additional_properties_request_instance.to_dict() +test_inline_freeform_additional_properties_request_dict = test_inline_freeform_additional_properties_request_instance.model_dump(by_alias=True) # create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict -test_inline_freeform_additional_properties_request_from_dict = TestInlineFreeformAdditionalPropertiesRequest.from_dict(test_inline_freeform_additional_properties_request_dict) +test_inline_freeform_additional_properties_request_from_dict = TestInlineFreeformAdditionalPropertiesRequest.model_validate(test_inline_freeform_additional_properties_request_dict) ``` [[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-aiohttp/docs/TestModelWithEnumDefault.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestModelWithEnumDefault.md index 7d46e86deba4..1f63056fe0f1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/TestModelWithEnumDefault.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestModelWithEnumDefault.md @@ -19,14 +19,14 @@ from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDe # TODO update the JSON string below json = "{}" # create an instance of TestModelWithEnumDefault from a JSON string -test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json) +test_model_with_enum_default_instance = TestModelWithEnumDefault.model_validate_json(json) # print the JSON string representation of the object -print(TestModelWithEnumDefault.to_json()) +print(test_model_with_enum_default_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict() +test_model_with_enum_default_dict = test_model_with_enum_default_instance.model_dump(by_alias=True) # create an instance of TestModelWithEnumDefault from a dict -test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict) +test_model_with_enum_default_from_dict = TestModelWithEnumDefault.model_validate(test_model_with_enum_default_dict) ``` [[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-aiohttp/docs/TestObjectForMultipartRequestsRequestMarker.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestObjectForMultipartRequestsRequestMarker.md index ff0ca9ee00ac..bb685d44835a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/TestObjectForMultipartRequestsRequestMarker.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestObjectForMultipartRequestsRequestMarker.md @@ -15,14 +15,14 @@ from petstore_api.models.test_object_for_multipart_requests_request_marker impor # TODO update the JSON string below json = "{}" # create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string -test_object_for_multipart_requests_request_marker_instance = TestObjectForMultipartRequestsRequestMarker.from_json(json) +test_object_for_multipart_requests_request_marker_instance = TestObjectForMultipartRequestsRequestMarker.model_validate_json(json) # print the JSON string representation of the object -print(TestObjectForMultipartRequestsRequestMarker.to_json()) +print(test_object_for_multipart_requests_request_marker_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_object_for_multipart_requests_request_marker_dict = test_object_for_multipart_requests_request_marker_instance.to_dict() +test_object_for_multipart_requests_request_marker_dict = test_object_for_multipart_requests_request_marker_instance.model_dump(by_alias=True) # create an instance of TestObjectForMultipartRequestsRequestMarker from a dict -test_object_for_multipart_requests_request_marker_from_dict = TestObjectForMultipartRequestsRequestMarker.from_dict(test_object_for_multipart_requests_request_marker_dict) +test_object_for_multipart_requests_request_marker_from_dict = TestObjectForMultipartRequestsRequestMarker.model_validate(test_object_for_multipart_requests_request_marker_dict) ``` [[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-aiohttp/docs/Tiger.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Tiger.md index f1cf2133f0f7..90c7d8770979 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/Tiger.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Tiger.md @@ -15,14 +15,14 @@ from petstore_api.models.tiger import Tiger # TODO update the JSON string below json = "{}" # create an instance of Tiger from a JSON string -tiger_instance = Tiger.from_json(json) +tiger_instance = Tiger.model_validate_json(json) # print the JSON string representation of the object -print(Tiger.to_json()) +print(tiger_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tiger_dict = tiger_instance.to_dict() +tiger_dict = tiger_instance.model_dump(by_alias=True) # create an instance of Tiger from a dict -tiger_from_dict = Tiger.from_dict(tiger_dict) +tiger_from_dict = Tiger.model_validate(tiger_dict) ``` [[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-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md b/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md index 68cd00ab0a7a..0b411bf5df7b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalModelListProperties.md @@ -15,14 +15,14 @@ from petstore_api.models.unnamed_dict_with_additional_model_list_properties impo # TODO update the JSON string below json = "{}" # create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string -unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.from_json(json) +unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.model_validate_json(json) # print the JSON string representation of the object -print(UnnamedDictWithAdditionalModelListProperties.to_json()) +print(unnamed_dict_with_additional_model_list_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.to_dict() +unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.model_dump(by_alias=True) # create an instance of UnnamedDictWithAdditionalModelListProperties from a dict -unnamed_dict_with_additional_model_list_properties_from_dict = UnnamedDictWithAdditionalModelListProperties.from_dict(unnamed_dict_with_additional_model_list_properties_dict) +unnamed_dict_with_additional_model_list_properties_from_dict = UnnamedDictWithAdditionalModelListProperties.model_validate(unnamed_dict_with_additional_model_list_properties_dict) ``` [[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-aiohttp/docs/UnnamedDictWithAdditionalStringListProperties.md b/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalStringListProperties.md index 045b0e22ad09..def639720586 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalStringListProperties.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/UnnamedDictWithAdditionalStringListProperties.md @@ -15,14 +15,14 @@ from petstore_api.models.unnamed_dict_with_additional_string_list_properties imp # TODO update the JSON string below json = "{}" # create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string -unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.from_json(json) +unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.model_validate_json(json) # print the JSON string representation of the object -print(UnnamedDictWithAdditionalStringListProperties.to_json()) +print(unnamed_dict_with_additional_string_list_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.to_dict() +unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.model_dump(by_alias=True) # create an instance of UnnamedDictWithAdditionalStringListProperties from a dict -unnamed_dict_with_additional_string_list_properties_from_dict = UnnamedDictWithAdditionalStringListProperties.from_dict(unnamed_dict_with_additional_string_list_properties_dict) +unnamed_dict_with_additional_string_list_properties_from_dict = UnnamedDictWithAdditionalStringListProperties.model_validate(unnamed_dict_with_additional_string_list_properties_dict) ``` [[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-aiohttp/docs/UploadFileWithAdditionalPropertiesRequestObject.md b/samples/openapi3/client/petstore/python-aiohttp/docs/UploadFileWithAdditionalPropertiesRequestObject.md index 141027780371..35be1642e660 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/UploadFileWithAdditionalPropertiesRequestObject.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/UploadFileWithAdditionalPropertiesRequestObject.md @@ -16,14 +16,14 @@ from petstore_api.models.upload_file_with_additional_properties_request_object i # TODO update the JSON string below json = "{}" # create an instance of UploadFileWithAdditionalPropertiesRequestObject from a JSON string -upload_file_with_additional_properties_request_object_instance = UploadFileWithAdditionalPropertiesRequestObject.from_json(json) +upload_file_with_additional_properties_request_object_instance = UploadFileWithAdditionalPropertiesRequestObject.model_validate_json(json) # print the JSON string representation of the object -print(UploadFileWithAdditionalPropertiesRequestObject.to_json()) +print(upload_file_with_additional_properties_request_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -upload_file_with_additional_properties_request_object_dict = upload_file_with_additional_properties_request_object_instance.to_dict() +upload_file_with_additional_properties_request_object_dict = upload_file_with_additional_properties_request_object_instance.model_dump(by_alias=True) # create an instance of UploadFileWithAdditionalPropertiesRequestObject from a dict -upload_file_with_additional_properties_request_object_from_dict = UploadFileWithAdditionalPropertiesRequestObject.from_dict(upload_file_with_additional_properties_request_object_dict) +upload_file_with_additional_properties_request_object_from_dict = UploadFileWithAdditionalPropertiesRequestObject.model_validate(upload_file_with_additional_properties_request_object_dict) ``` [[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-aiohttp/docs/User.md b/samples/openapi3/client/petstore/python-aiohttp/docs/User.md index c45d26d27043..8f4ae3d04712 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/User.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/User.md @@ -22,14 +22,14 @@ from petstore_api.models.user import User # TODO update the JSON string below json = "{}" # create an instance of User from a JSON string -user_instance = User.from_json(json) +user_instance = User.model_validate_json(json) # print the JSON string representation of the object -print(User.to_json()) +print(user_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -user_dict = user_instance.to_dict() +user_dict = user_instance.model_dump(by_alias=True) # create an instance of User from a dict -user_from_dict = User.from_dict(user_dict) +user_from_dict = User.model_validate(user_dict) ``` [[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-aiohttp/docs/WithNestedOneOf.md b/samples/openapi3/client/petstore/python-aiohttp/docs/WithNestedOneOf.md index e7bbbc28fc2d..12d648bb920d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/WithNestedOneOf.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/WithNestedOneOf.md @@ -17,14 +17,14 @@ from petstore_api.models.with_nested_one_of import WithNestedOneOf # TODO update the JSON string below json = "{}" # create an instance of WithNestedOneOf from a JSON string -with_nested_one_of_instance = WithNestedOneOf.from_json(json) +with_nested_one_of_instance = WithNestedOneOf.model_validate_json(json) # print the JSON string representation of the object -print(WithNestedOneOf.to_json()) +print(with_nested_one_of_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -with_nested_one_of_dict = with_nested_one_of_instance.to_dict() +with_nested_one_of_dict = with_nested_one_of_instance.model_dump(by_alias=True) # create an instance of WithNestedOneOf from a dict -with_nested_one_of_from_dict = WithNestedOneOf.from_dict(with_nested_one_of_dict) +with_nested_one_of_from_dict = WithNestedOneOf.model_validate(with_nested_one_of_dict) ``` [[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-aiohttp/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py index 291b5e55e353..9c810c176590 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesAnyType(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesAnyType(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesAnyType from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesAnyType from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py index 4b2cc457e499..ddbba0f2757e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesClass(BaseModel): """ @@ -37,53 +38,27 @@ class AdditionalPropertiesClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py index 00707c3c4818..75df3dc97cf4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesObject(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py index d8049b519ed0..a3dea0ab8ee6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesWithDescriptionOnly(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py index 03f554592935..69652540470a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AllOfSuperModel(BaseModel): """ @@ -36,52 +37,27 @@ class AllOfSuperModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AllOfSuperModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AllOfSuperModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py index 44c7da9114a8..e76a1fde6648 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.single_ref_type import SingleRefType from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AllOfWithSingleRef(BaseModel): """ @@ -38,53 +39,27 @@ class AllOfWithSingleRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AllOfWithSingleRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AllOfWithSingleRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "username": obj.get("username"), - "SingleRefType": obj.get("SingleRefType") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py index 56bec73a9ccd..2895047545a5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -60,52 +61,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Union[Cat, Dog]]: - """Create an instance of Animal from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[Cat, Dog]]: - """Create an instance of Animal from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'Cat': - return import_module("petstore_api.models.cat").Cat.from_dict(obj) - if object_type == 'Dog': - return import_module("petstore_api.models.dog").Dog.from_dict(obj) - - raise ValueError("Animal failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py index f6d277e79498..b86b03be3591 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py @@ -13,8 +13,6 @@ from __future__ import annotations -from inspect import getfullargspec -import json import pprint import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator @@ -22,135 +20,56 @@ from typing_extensions import Annotated from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field +from pydantic import Field, RootModel ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] -class AnyOfColor(BaseModel): + +class AnyOfColor(RootModel[Union[List[int], str]]): """ Any of RGB array, RGBA array, or hex string. """ - # data type: List[int] - anyof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") - # data type: List[int] - anyof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") - # data type: str - anyof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") - if TYPE_CHECKING: - actual_instance: Optional[Union[List[int], str]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { "List[int]", "str" } - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfColor.model_construct() - error_messages = [] - # validate data type: List[int] - try: - instance.anyof_schema_1_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: List[int] - try: - instance.anyof_schema_2_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.anyof_schema_3_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return v + root: Union[List[int], str] = Field( + ... + ) + + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ + + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Self: - return cls.from_json(json.dumps(obj)) + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - # deserialize data into List[int] - try: - # validation - instance.anyof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_1_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into List[int] - try: - # validation - instance.anyof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_2_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.anyof_schema_3_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_3_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) + return self.model_dump_json(by_alias=True, exclude_none=True) - def to_dict(self) -> Optional[Union[Dict[str, Any], List[int], str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py index c949e136f415..a632d3c382d6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -from inspect import getfullargspec -import json import pprint import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator @@ -23,112 +21,56 @@ from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field +from pydantic import Field, RootModel ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] -class AnyOfPig(BaseModel): + +class AnyOfPig(RootModel[Union[BasquePig, DanishPig]]): """ AnyOfPig """ - # data type: BasquePig - anyof_schema_1_validator: Optional[BasquePig] = None - # data type: DanishPig - anyof_schema_2_validator: Optional[DanishPig] = None - if TYPE_CHECKING: - actual_instance: Optional[Union[BasquePig, DanishPig]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { "BasquePig", "DanishPig" } - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfPig.model_construct() - error_messages = [] - # validate data type: BasquePig - if not isinstance(v, BasquePig): - error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") - else: - return v - - # validate data type: DanishPig - if not isinstance(v, DanishPig): - error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") - else: - return v - - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return v + root: Union[BasquePig, DanishPig] = Field( + ... + ) + + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ + + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Self: - return cls.from_json(json.dumps(obj)) + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - # anyof_schema_1_validator: Optional[BasquePig] = None - try: - instance.actual_instance = BasquePig.from_json(json_str) - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # anyof_schema_2_validator: Optional[DanishPig] = None - try: - instance.actual_instance = DanishPig.from_json(json_str) - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) + return self.model_dump_json(by_alias=True, exclude_none=True) - def to_dict(self) -> Optional[Union[Dict[str, Any], BasquePig, DanishPig]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py index 4f8eeda66c30..dfc9ac6c4ca5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfArrayOfModel(BaseModel): """ @@ -37,64 +38,27 @@ class ArrayOfArrayOfModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) - _items = [] - if self.another_property: - for _item_another_property in self.another_property: - if _item_another_property: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] - ) - _dict['another_property'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "another_property": [ - [Tag.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["another_property"] - ] if obj.get("another_property") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py index 02b0f6d657f4..3ad948c9440d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfArrayOfNumberOnly(BaseModel): """ @@ -36,52 +37,27 @@ class ArrayOfArrayOfNumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfNumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfNumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "ArrayArrayNumber": obj.get("ArrayArrayNumber") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py index b22632b0ce4d..1d4adc5a950a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfNumberOnly(BaseModel): """ @@ -36,52 +37,27 @@ class ArrayOfNumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfNumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfNumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "ArrayNumber": obj.get("ArrayNumber") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py index e8f8acf67cc0..5adbf20df093 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py @@ -22,7 +22,8 @@ from typing_extensions import Annotated from petstore_api.models.read_only_first import ReadOnlyFirst from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayTest(BaseModel): """ @@ -41,67 +42,27 @@ class ArrayTest(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) - _items = [] - if self.array_array_of_model: - for _item_array_array_of_model in self.array_array_of_model: - if _item_array_array_of_model: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] - ) - _dict['array_array_of_model'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "array_of_string": obj.get("array_of_string"), - "array_of_nullable_float": obj.get("array_of_nullable_float"), - "array_array_of_integer": obj.get("array_array_of_integer"), - "array_array_of_model": [ - [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["array_array_of_model"] - ] if obj.get("array_array_of_model") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py index f13c270b56b5..9503c06d45bc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -59,52 +60,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Union[PrimitiveString, Info]]: - """Create an instance of BaseDiscriminator from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[PrimitiveString, Info]]: - """Create an instance of BaseDiscriminator from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'PrimitiveString': - return import_module("petstore_api.models.primitive_string").PrimitiveString.from_dict(obj) - if object_type == 'Info': - return import_module("petstore_api.models.info").Info.from_dict(obj) - - raise ValueError("BaseDiscriminator failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py index a1f32a6edcfc..34c4a06b6cbd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class BasquePig(BaseModel): """ @@ -37,53 +38,27 @@ class BasquePig(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of BasquePig from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of BasquePig from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py index 088e6ad3b873..732c1aa3042a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Bathing(BaseModel): """ Bathing """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning_deep'] = Field( + ..., + description="task_name of the Bathing", + alias="task_name" + ) + function_name: Literal['care_nourish'] = Field( + ..., + description="function_name of the Bathing", + alias="function_name" + ) content: StrictStr __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -52,54 +61,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Bathing from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Bathing from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py index b3c20af54440..28449afd3e5a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Capitalization(BaseModel): """ @@ -41,57 +42,27 @@ class Capitalization(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Capitalization from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Capitalization from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "smallCamel": obj.get("smallCamel"), - "CapitalCamel": obj.get("CapitalCamel"), - "small_Snake": obj.get("small_Snake"), - "Capital_Snake": obj.get("Capital_Snake"), - "SCA_ETH_Flow_Points": obj.get("SCA_ETH_Flow_Points"), - "ATT_NAME": obj.get("ATT_NAME") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py index 0c2c9788dca3..4a93e75fad72 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Cat(Animal): """ @@ -37,54 +38,27 @@ class Cat(Animal): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Cat from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Cat from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") if obj.get("color") is not None else 'red', - "declawed": obj.get("declawed") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py index dcc6247b5ac7..aa4daee49387 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Category(BaseModel): """ @@ -37,53 +38,27 @@ class Category(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Category from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Category from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") if obj.get("name") is not None else 'default-name' - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py index f98247ae0fb5..208e5958632d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CircularAllOfRef(BaseModel): """ @@ -37,61 +38,28 @@ class CircularAllOfRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CircularAllOfRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in second_circular_all_of_ref (list) - _items = [] - if self.second_circular_all_of_ref: - for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: - if _item_second_circular_all_of_ref: - _items.append(_item_second_circular_all_of_ref.to_dict()) - _dict['secondCircularAllOfRef'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CircularAllOfRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name"), - "secondCircularAllOfRef": [SecondCircularAllOfRef.from_dict(_item) for _item in obj["secondCircularAllOfRef"]] if obj.get("secondCircularAllOfRef") is not None else None - }) - return _obj from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py index 3b2854caaac2..f3a5c5c72ceb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CircularReferenceModel(BaseModel): """ @@ -37,57 +38,28 @@ class CircularReferenceModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CircularReferenceModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested - if self.nested: - _dict['nested'] = self.nested.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CircularReferenceModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested": FirstRef.from_dict(obj["nested"]) if obj.get("nested") is not None else None - }) - return _obj from petstore_api.models.first_ref import FirstRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py index 6def0e52d146..39b738f37734 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ClassModel(BaseModel): """ @@ -36,52 +37,27 @@ class ClassModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ClassModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ClassModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_class": obj.get("_class") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py index 1c12c9a145c8..f0cce9f3cb96 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Client(BaseModel): """ @@ -36,52 +37,27 @@ class Client(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Client from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Client from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "client": obj.get("client") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py index bb740fb597d4..5197fe58ecc6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py @@ -18,150 +18,55 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] -class Color(BaseModel): +class Color(RootModel[Union[List[int], str]]): """ RGB array, RGBA array, or hex string. """ - # data type: List[int] - oneof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") - # data type: List[int] - oneof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") - # data type: str - oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") - actual_instance: Optional[Union[List[int], str]] = None - one_of_schemas: Set[str] = { "List[int]", "str" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[List[int], str, None] = Field( + None ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - if v is None: - return v - - instance = Color.model_construct() - error_messages = [] - match = 0 - # validate data type: List[int] - try: - instance.oneof_schema_1_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: List[int] - try: - instance.oneof_schema_2_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.oneof_schema_3_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: Optional[str]) -> Self: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - if json_str is None: - return instance - - error_messages = [] - match = 0 - - # deserialize data into List[int] - try: - # validation - instance.oneof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_1_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into List[int] - try: - # validation - instance.oneof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_2_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.oneof_schema_3_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_3_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], List[int], str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py index 2ed3aa42bf99..9f3f914c2b72 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py @@ -22,7 +22,8 @@ from typing import Any, ClassVar, Dict, List, Union from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -60,53 +61,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[HuntingDog]]: - """Create an instance of Creature from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of info - if self.info: - _dict['info'] = self.info.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[HuntingDog]]: - """Create an instance of Creature from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'HuntingDog': - return import_module("petstore_api.models.hunting_dog").HuntingDog.from_dict(obj) - - raise ValueError("Creature failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py index e7927446c238..9b70835e860e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CreatureInfo(BaseModel): """ @@ -36,52 +37,27 @@ class CreatureInfo(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CreatureInfo from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CreatureInfo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py index 061e16a486a5..b9521312c8e8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DanishPig(BaseModel): """ @@ -37,53 +38,27 @@ class DanishPig(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DanishPig from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DanishPig from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "size": obj.get("size") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py index bb4747a1e18c..3c7fbe91d2f2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DeprecatedObject(BaseModel): """ @@ -36,52 +37,27 @@ class DeprecatedObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DeprecatedObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DeprecatedObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py index 2e8d4a6d7633..9f5f1144a513 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List from petstore_api.models.discriminator_all_of_super import DiscriminatorAllOfSuper from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DiscriminatorAllOfSub(DiscriminatorAllOfSuper): """ @@ -36,52 +37,27 @@ class DiscriminatorAllOfSub(DiscriminatorAllOfSuper): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DiscriminatorAllOfSub from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DiscriminatorAllOfSub from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "elementType": obj.get("elementType") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py index ee910f90ea69..f2e5c978592b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -58,50 +59,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Union[DiscriminatorAllOfSub]]: - """Create an instance of DiscriminatorAllOfSuper from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[DiscriminatorAllOfSub]]: - """Create an instance of DiscriminatorAllOfSuper from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'DiscriminatorAllOfSub': - return import_module("petstore_api.models.discriminator_all_of_sub").DiscriminatorAllOfSub.from_dict(obj) - - raise ValueError("DiscriminatorAllOfSuper failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py index a0f4ed786b4e..ee2df1d87aac 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Dog(Animal): """ @@ -37,54 +38,27 @@ class Dog(Animal): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Dog from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Dog from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") if obj.get("color") is not None else 'red', - "breed": obj.get("breed") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py index 3050cbf66dc4..f2ddcef5972a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DummyModel(BaseModel): """ @@ -37,57 +38,28 @@ class DummyModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DummyModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of self_ref - if self.self_ref: - _dict['self_ref'] = self.self_ref.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DummyModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "self_ref": SelfReferenceModel.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None - }) - return _obj from petstore_api.models.self_reference_model import SelfReferenceModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index 68ceb962b03e..5a46c33280ca 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -20,14 +20,21 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumArrays(BaseModel): """ EnumArrays """ # noqa: E501 - just_symbol: Optional[StrictStr] = None - array_enum: Optional[List[StrictStr]] = None + just_symbol: Optional[Literal['>=', '$']] = Field( + None, + description="just_symbol of the EnumArrays" + ) + array_enum: Optional[List[Literal['fish', 'crab']]] = Field( + None, + description="array_enum of the EnumArrays" + ) __properties: ClassVar[List[str]] = ["just_symbol", "array_enum"] @field_validator('just_symbol') @@ -58,53 +65,27 @@ def array_enum_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumArrays from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumArrays from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "just_symbol": obj.get("just_symbol"), - "array_enum": obj.get("array_enum") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py index 9d97e3fd16d4..b51873522c71 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.data_output_format import DataOutputFormat from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumRefWithDefaultValue(BaseModel): """ @@ -37,52 +38,27 @@ class EnumRefWithDefaultValue(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumRefWithDefaultValue from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumRefWithDefaultValue from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "report_format": obj.get("report_format") if obj.get("report_format") is not None else DataOutputFormat.JSON - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index b7e6ec36230f..cc8235f31d2f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -26,19 +26,43 @@ from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumTest(BaseModel): """ EnumTest """ # noqa: E501 - enum_string: Optional[StrictStr] = None - enum_string_required: StrictStr - enum_integer_default: Optional[StrictInt] = 5 - enum_integer: Optional[StrictInt] = None - enum_number: Optional[float] = None - enum_string_single_member: Optional[StrictStr] = None - enum_integer_single_member: Optional[StrictInt] = None + enum_string: Optional[Literal['UPPER', 'lower', '']] = Field( + None, + description="enum_string of the EnumTest" + ) + enum_string_required: Literal['UPPER', 'lower', ''] = Field( + ..., + description="enum_string_required of the EnumTest" + ) + enum_integer_default: Optional[Literal[1, 5, 14]] = Field( + None, + description="enum_integer_default of the EnumTest" + ) + enum_integer: Optional[Literal[1, -1]] = Field( + None, + description="enum_integer of the EnumTest" + ) + enum_number: Optional[Literal[1.1, -1.2]] = Field( + None, + description="enum_number of the EnumTest" + ) + enum_string_single_member: Literal['abc'] = Field( + None, + description="enum_string_single_member of the EnumTest", + alias="enum_string_single_member" + ) + enum_integer_single_member: Literal['100'] = Field( + None, + description="enum_integer_single_member of the EnumTest", + alias="enum_integer_single_member" + ) outer_enum: Optional[OuterEnum] = Field(default=None, alias="outerEnum") outer_enum_integer: Optional[OuterEnumInteger] = Field(default=None, alias="outerEnumInteger") outer_enum_default_value: Optional[OuterEnumDefaultValue] = Field(default=OuterEnumDefaultValue.PLACED, alias="outerEnumDefaultValue") @@ -121,69 +145,27 @@ def enum_integer_single_member_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if outer_enum (nullable) is None - # and model_fields_set contains the field - if self.outer_enum is None and "outer_enum" in self.model_fields_set: - _dict['outerEnum'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "enum_string": obj.get("enum_string"), - "enum_string_required": obj.get("enum_string_required"), - "enum_integer_default": obj.get("enum_integer_default") if obj.get("enum_integer_default") is not None else 5, - "enum_integer": obj.get("enum_integer"), - "enum_number": obj.get("enum_number"), - "enum_string_single_member": obj.get("enum_string_single_member"), - "enum_integer_single_member": obj.get("enum_integer_single_member"), - "outerEnum": obj.get("outerEnum"), - "outerEnumInteger": obj.get("outerEnumInteger"), - "outerEnumDefaultValue": obj.get("outerEnumDefaultValue") if obj.get("outerEnumDefaultValue") is not None else OuterEnumDefaultValue.PLACED, - "outerEnumIntegerDefaultValue": obj.get("outerEnumIntegerDefaultValue") if obj.get("outerEnumIntegerDefaultValue") is not None else OuterEnumIntegerDefaultValue.NUMBER_0, - "enumNumberVendorExt": obj.get("enumNumberVendorExt"), - "enumStringVendorExt": obj.get("enumStringVendorExt") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py index 1183b314fdd0..ed0623f5e1ca 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Feeding(BaseModel): """ Feeding """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning'] = Field( + ..., + description="task_name of the Feeding", + alias="task_name" + ) + function_name: Literal['care_nourish'] = Field( + ..., + description="function_name of the Feeding", + alias="function_name" + ) content: StrictStr __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -52,54 +61,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Feeding from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Feeding from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py index 0ecacf44bb8e..39a9df75cceb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class File(BaseModel): """ @@ -36,52 +37,27 @@ class File(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of File from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of File from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "sourceURI": obj.get("sourceURI") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py index c533c0777b24..8a35d95893ab 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.file import File from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FileSchemaTestClass(BaseModel): """ @@ -38,63 +39,27 @@ class FileSchemaTestClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FileSchemaTestClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of file - if self.file: - _dict['file'] = self.file.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in files (list) - _items = [] - if self.files: - for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) - _dict['files'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FileSchemaTestClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "file": File.from_dict(obj["file"]) if obj.get("file") is not None else None, - "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py index 6aa0f722d874..13bee22b64e4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FirstRef(BaseModel): """ @@ -37,57 +38,28 @@ class FirstRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FirstRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of self_ref - if self.self_ref: - _dict['self_ref'] = self.self_ref.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FirstRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "self_ref": SecondRef.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None - }) - return _obj from petstore_api.models.second_ref import SecondRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py index 67b29f1ab87c..a1b2ca180494 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Foo(BaseModel): """ @@ -36,52 +37,27 @@ class Foo(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Foo from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Foo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar") if obj.get("bar") is not None else 'bar' - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py index ae191aad80a8..3fe6d71bf00e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.foo import Foo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FooGetDefaultResponse(BaseModel): """ @@ -37,55 +38,27 @@ class FooGetDefaultResponse(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FooGetDefaultResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of string - if self.string: - _dict['string'] = self.string.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FooGetDefaultResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "string": Foo.from_dict(obj["string"]) if obj.get("string") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py index 8d70a96f3a7c..368933863a9a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py @@ -24,7 +24,8 @@ from typing_extensions import Annotated from uuid import UUID from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FormatTest(BaseModel): """ @@ -96,68 +97,27 @@ def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FormatTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FormatTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "integer": obj.get("integer"), - "int32": obj.get("int32"), - "int64": obj.get("int64"), - "number": obj.get("number"), - "float": obj.get("float"), - "double": obj.get("double"), - "decimal": obj.get("decimal"), - "string": obj.get("string"), - "string_with_double_quote_pattern": obj.get("string_with_double_quote_pattern"), - "byte": obj.get("byte"), - "binary": obj.get("binary"), - "date": obj.get("date"), - "dateTime": obj.get("dateTime"), - "uuid": obj.get("uuid"), - "password": obj.get("password"), - "pattern_with_digits": obj.get("pattern_with_digits"), - "pattern_with_digits_and_delimiter": obj.get("pattern_with_digits_and_delimiter") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py index 2137bc880484..07a8241f5eb4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HasOnlyReadOnly(BaseModel): """ @@ -37,57 +38,27 @@ class HasOnlyReadOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HasOnlyReadOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * OpenAPI `readOnly` fields are excluded. - """ - excluded_fields: Set[str] = set([ - "bar", - "foo", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HasOnlyReadOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar"), - "foo": obj.get("foo") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py index 4dbdd852097f..eb842ad8defc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HealthCheckResult(BaseModel): """ @@ -36,57 +37,27 @@ class HealthCheckResult(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HealthCheckResult from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if nullable_message (nullable) is None - # and model_fields_set contains the field - if self.nullable_message is None and "nullable_message" in self.model_fields_set: - _dict['NullableMessage'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HealthCheckResult from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "NullableMessage": obj.get("NullableMessage") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py index cd678616f62f..9460c3da660e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py @@ -22,7 +22,8 @@ from petstore_api.models.creature import Creature from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HuntingDog(Creature): """ @@ -38,57 +39,27 @@ class HuntingDog(Creature): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HuntingDog from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of info - if self.info: - _dict['info'] = self.info.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HuntingDog from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "info": CreatureInfo.from_dict(obj["info"]) if obj.get("info") is not None else None, - "type": obj.get("type"), - "isTrained": obj.get("isTrained") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py index 5a15b5f9f52f..9a4cf4070256 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.base_discriminator import BaseDiscriminator from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Info(BaseDiscriminator): """ @@ -37,56 +38,27 @@ class Info(BaseDiscriminator): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Info from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of val - if self.val: - _dict['val'] = self.val.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Info from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_typeName": obj.get("_typeName"), - "val": BaseDiscriminator.from_dict(obj["val"]) if obj.get("val") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py index 27816b995f53..3165bf3a065d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class InnerDictWithProperty(BaseModel): """ @@ -36,52 +37,27 @@ class InnerDictWithProperty(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of InnerDictWithProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of InnerDictWithProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "aProperty": obj.get("aProperty") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py index 63870cca83ed..cc09b8ea0c29 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class InputAllOf(BaseModel): """ @@ -37,64 +38,27 @@ class InputAllOf(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of InputAllOf from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) - _field_dict = {} - if self.some_data: - for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - _dict['some_data'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of InputAllOf from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "some_data": dict( - (_k, Tag.from_dict(_v)) - for _k, _v in obj["some_data"].items() - ) - if obj.get("some_data") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py index f2a5a0a2d4a3..c66bf1ab9772 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py @@ -18,127 +18,55 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] -class IntOrString(BaseModel): +class IntOrString(RootModel[Union[int, str]]): """ IntOrString """ - # data type: int - oneof_schema_1_validator: Optional[Annotated[int, Field(strict=True, ge=10)]] = None - # data type: str - oneof_schema_2_validator: Optional[StrictStr] = None - actual_instance: Optional[Union[int, str]] = None - one_of_schemas: Set[str] = { "int", "str" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[int, str] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = IntOrString.model_construct() - error_messages = [] - match = 0 - # validate data type: int - try: - instance.oneof_schema_1_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.oneof_schema_2_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into int - try: - # validation - instance.oneof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_1_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.oneof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_2_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py index ab12a7fac521..0a5f1ac36d43 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ListClass(BaseModel): """ @@ -36,52 +37,27 @@ class ListClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ListClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ListClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "123-list": obj.get("123-list") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index a9bd000ad9ba..bd926af80b11 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MapOfArrayOfModel(BaseModel): """ @@ -37,68 +38,27 @@ class MapOfArrayOfModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MapOfArrayOfModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array) - _field_dict_of_array = {} - if self.shop_id_to_org_online_lip_map: - for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ - _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] - ] - _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MapOfArrayOfModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "shopIdToOrgOnlineLipMap": dict( - (_k, - [Tag.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("shopIdToOrgOnlineLipMap", {}).items() - ) - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index 2a056ab5532a..591b729eb6a1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -20,14 +20,18 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MapTest(BaseModel): """ MapTest """ # noqa: E501 map_map_of_string: Optional[Dict[str, Dict[str, StrictStr]]] = None - map_of_enum_string: Optional[Dict[str, StrictStr]] = None + map_of_enum_string: Optional[Literal['UPPER', 'lower']] = Field( + None, + description="map_of_enum_string of the MapTest" + ) direct_map: Optional[Dict[str, StrictBool]] = None indirect_map: Optional[Dict[str, StrictBool]] = None __properties: ClassVar[List[str]] = ["map_map_of_string", "map_of_enum_string", "direct_map", "indirect_map"] @@ -50,55 +54,27 @@ def map_of_enum_string_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MapTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MapTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "map_map_of_string": obj.get("map_map_of_string"), - "map_of_enum_string": obj.get("map_of_enum_string"), - "direct_map": obj.get("direct_map"), - "indirect_map": obj.get("indirect_map") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py index 46998dfb5c68..d4f415fe0afa 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -23,7 +23,8 @@ from uuid import UUID from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): """ @@ -41,66 +42,27 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in map (dict) - _field_dict = {} - if self.map: - for _key_map in self.map: - if self.map[_key_map]: - _field_dict[_key_map] = self.map[_key_map].to_dict() - _dict['map'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "uuid": obj.get("uuid"), - "dateTime": obj.get("dateTime"), - "map": dict( - (_k, Animal.from_dict(_v)) - for _k, _v in obj["map"].items() - ) - if obj.get("map") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py index d6012c57fbd7..f4186542b9e7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Model200Response(BaseModel): """ @@ -37,53 +38,27 @@ class Model200Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Model200Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Model200Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "class": obj.get("class") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py index 005c77823bef..4556075a0995 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelApiResponse(BaseModel): """ @@ -38,54 +39,27 @@ class ModelApiResponse(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelApiResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelApiResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "code": obj.get("code"), - "type": obj.get("type"), - "message": obj.get("message") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py index 9e36a6ac7e48..eed3b9237d74 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelField(BaseModel): """ @@ -36,52 +37,27 @@ class ModelField(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelField from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelField from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "field": obj.get("field") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py index a8c0f53f6c19..a6760c8a3650 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelReturn(BaseModel): """ @@ -36,52 +37,27 @@ class ModelReturn(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelReturn from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelReturn from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "return": obj.get("return") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py index 177a8359468f..b50d7f9ad4b3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py @@ -22,7 +22,8 @@ from petstore_api.models.file import File from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MultiArrays(BaseModel): """ @@ -39,67 +40,27 @@ class MultiArrays(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MultiArrays from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - # override the default output from pydantic by calling `to_dict()` of each item in files (list) - _items = [] - if self.files: - for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) - _dict['files'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MultiArrays from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py index f33b2ecb18be..67265006c173 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Name(BaseModel): """ @@ -39,59 +40,27 @@ class Name(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Name from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * OpenAPI `readOnly` fields are excluded. - """ - excluded_fields: Set[str] = set([ - "snake_case", - "var_123_number", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Name from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "snake_case": obj.get("snake_case"), - "property": obj.get("property"), - "123Number": obj.get("123Number") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py index 9d1414954830..19824ad3bfcc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NullableClass(BaseModel): """ @@ -50,131 +51,27 @@ class NullableClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NullableClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if required_integer_prop (nullable) is None - # and model_fields_set contains the field - if self.required_integer_prop is None and "required_integer_prop" in self.model_fields_set: - _dict['required_integer_prop'] = None - - # set to None if integer_prop (nullable) is None - # and model_fields_set contains the field - if self.integer_prop is None and "integer_prop" in self.model_fields_set: - _dict['integer_prop'] = None - - # set to None if number_prop (nullable) is None - # and model_fields_set contains the field - if self.number_prop is None and "number_prop" in self.model_fields_set: - _dict['number_prop'] = None - - # set to None if boolean_prop (nullable) is None - # and model_fields_set contains the field - if self.boolean_prop is None and "boolean_prop" in self.model_fields_set: - _dict['boolean_prop'] = None - - # set to None if string_prop (nullable) is None - # and model_fields_set contains the field - if self.string_prop is None and "string_prop" in self.model_fields_set: - _dict['string_prop'] = None - - # set to None if date_prop (nullable) is None - # and model_fields_set contains the field - if self.date_prop is None and "date_prop" in self.model_fields_set: - _dict['date_prop'] = None - - # set to None if datetime_prop (nullable) is None - # and model_fields_set contains the field - if self.datetime_prop is None and "datetime_prop" in self.model_fields_set: - _dict['datetime_prop'] = None - - # set to None if array_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.array_nullable_prop is None and "array_nullable_prop" in self.model_fields_set: - _dict['array_nullable_prop'] = None - - # set to None if array_and_items_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.array_and_items_nullable_prop is None and "array_and_items_nullable_prop" in self.model_fields_set: - _dict['array_and_items_nullable_prop'] = None - - # set to None if object_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.object_nullable_prop is None and "object_nullable_prop" in self.model_fields_set: - _dict['object_nullable_prop'] = None - - # set to None if object_and_items_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.object_and_items_nullable_prop is None and "object_and_items_nullable_prop" in self.model_fields_set: - _dict['object_and_items_nullable_prop'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NullableClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "required_integer_prop": obj.get("required_integer_prop"), - "integer_prop": obj.get("integer_prop"), - "number_prop": obj.get("number_prop"), - "boolean_prop": obj.get("boolean_prop"), - "string_prop": obj.get("string_prop"), - "date_prop": obj.get("date_prop"), - "datetime_prop": obj.get("datetime_prop"), - "array_nullable_prop": obj.get("array_nullable_prop"), - "array_and_items_nullable_prop": obj.get("array_and_items_nullable_prop"), - "array_items_nullable": obj.get("array_items_nullable"), - "object_nullable_prop": obj.get("object_nullable_prop"), - "object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"), - "object_items_nullable": obj.get("object_items_nullable") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py index 2324745d7dd1..57dd94a70c10 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NullableProperty(BaseModel): """ @@ -48,58 +49,27 @@ def name_validate_regular_expression(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NullableProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if name (nullable) is None - # and model_fields_set contains the field - if self.name is None and "name" in self.model_fields_set: - _dict['name'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NullableProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py index 18c3ec953080..5745c6ae695f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NumberOnly(BaseModel): """ @@ -36,52 +37,27 @@ class NumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "JustNumber": obj.get("JustNumber") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py index 22b8bd401a1c..0823a0a2474b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictBool from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ObjectToTestAdditionalProperties(BaseModel): """ @@ -36,52 +37,27 @@ class ObjectToTestAdditionalProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ObjectToTestAdditionalProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ObjectToTestAdditionalProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "property": obj.get("property") if obj.get("property") is not None else False - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py index 4d76d9f5fc72..e9ef0f373e91 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.deprecated_object import DeprecatedObject from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ObjectWithDeprecatedFields(BaseModel): """ @@ -40,58 +41,27 @@ class ObjectWithDeprecatedFields(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ObjectWithDeprecatedFields from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of deprecated_ref - if self.deprecated_ref: - _dict['deprecatedRef'] = self.deprecated_ref.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ObjectWithDeprecatedFields from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "uuid": obj.get("uuid"), - "id": obj.get("id"), - "deprecatedRef": DeprecatedObject.from_dict(obj["deprecatedRef"]) if obj.get("deprecatedRef") is not None else None, - "bars": obj.get("bars") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index f742027e088a..0b8441532ba5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Order(BaseModel): """ @@ -31,7 +32,10 @@ class Order(BaseModel): pet_id: Optional[StrictInt] = Field(default=None, alias="petId") quantity: Optional[StrictInt] = None ship_date: Optional[datetime] = Field(default=None, alias="shipDate") - status: Optional[StrictStr] = Field(default=None, description="Order Status") + status: Optional[Literal['placed', 'approved', 'delivered']] = Field( + None, + description="Order Status" + ) complete: Optional[StrictBool] = False __properties: ClassVar[List[str]] = ["id", "petId", "quantity", "shipDate", "status", "complete"] @@ -52,57 +56,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Order from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Order from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "petId": obj.get("petId"), - "quantity": obj.get("quantity"), - "shipDate": obj.get("shipDate"), - "status": obj.get("status"), - "complete": obj.get("complete") if obj.get("complete") is not None else False - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py index 6a82d49970cb..fe85ee49ca06 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class OuterComposite(BaseModel): """ @@ -38,54 +39,27 @@ class OuterComposite(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OuterComposite from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OuterComposite from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "my_number": obj.get("my_number"), - "my_string": obj.get("my_string"), - "my_boolean": obj.get("my_boolean") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py index 4f453c2a8d0c..4daabab35807 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py @@ -22,7 +22,8 @@ from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class OuterObjectWithEnumProperty(BaseModel): """ @@ -39,58 +40,27 @@ class OuterObjectWithEnumProperty(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OuterObjectWithEnumProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if str_value (nullable) is None - # and model_fields_set contains the field - if self.str_value is None and "str_value" in self.model_fields_set: - _dict['str_value'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OuterObjectWithEnumProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "str_value": obj.get("str_value"), - "value": obj.get("value") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py index 5986da45ab04..347ed325ae05 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Parent(BaseModel): """ @@ -37,64 +38,27 @@ class Parent(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Parent from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) - _field_dict = {} - if self.optional_dict: - for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - _dict['optionalDict'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Parent from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "optionalDict": dict( - (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj["optionalDict"].items() - ) - if obj.get("optionalDict") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py index 84445b64043a..6cab92407738 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ParentWithOptionalDict(BaseModel): """ @@ -37,64 +38,27 @@ class ParentWithOptionalDict(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ParentWithOptionalDict from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) - _field_dict = {} - if self.optional_dict: - for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - _dict['optionalDict'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ParentWithOptionalDict from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "optionalDict": dict( - (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj["optionalDict"].items() - ) - if obj.get("optionalDict") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index be47c3b1a894..dbef9d16f443 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -23,7 +23,8 @@ from petstore_api.models.category import Category from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Pet(BaseModel): """ @@ -34,7 +35,10 @@ class Pet(BaseModel): name: StrictStr photo_urls: Annotated[List[StrictStr], Field(min_length=0)] = Field(alias="photoUrls") tags: Optional[List[Tag]] = None - status: Optional[StrictStr] = Field(default=None, description="pet status in the store") + status: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) __properties: ClassVar[List[str]] = ["id", "category", "name", "photoUrls", "tags", "status"] @field_validator('status') @@ -54,67 +58,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Pet from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of category - if self.category: - _dict['category'] = self.category.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Pet from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, - "name": obj.get("name"), - "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "status": obj.get("status") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py index b3a759e89b7b..6646e6d477cd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py @@ -19,122 +19,55 @@ from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] -class Pig(BaseModel): +class Pig(RootModel[Union[BasquePig, DanishPig]]): """ Pig """ - # data type: BasquePig - oneof_schema_1_validator: Optional[BasquePig] = None - # data type: DanishPig - oneof_schema_2_validator: Optional[DanishPig] = None - actual_instance: Optional[Union[BasquePig, DanishPig]] = None - one_of_schemas: Set[str] = { "BasquePig", "DanishPig" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[BasquePig, DanishPig] = Field( + ..., discriminator="class_name" ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - discriminator_value_class_map: Dict[str, str] = { - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = Pig.model_construct() - error_messages = [] - match = 0 - # validate data type: BasquePig - if not isinstance(v, BasquePig): - error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") - else: - match += 1 - # validate data type: DanishPig - if not isinstance(v, DanishPig): - error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into BasquePig - try: - instance.actual_instance = BasquePig.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into DanishPig - try: - instance.actual_instance = DanishPig.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], BasquePig, DanishPig]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py index 00bd38659577..bed85efa276c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.type import Type from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PonySizes(BaseModel): """ @@ -37,52 +38,27 @@ class PonySizes(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PonySizes from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PonySizes from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "type": obj.get("type") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py index 047cf0d481a9..8f972d517236 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PoopCleaning(BaseModel): """ PoopCleaning """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning'] = Field( + ..., + description="task_name of the PoopCleaning", + alias="task_name" + ) + function_name: Literal['care'] = Field( + ..., + description="function_name of the PoopCleaning", + alias="function_name" + ) content: StrictStr __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -52,54 +61,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PoopCleaning from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PoopCleaning from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py index 5a7065597861..a811f9d7c3f2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.base_discriminator import BaseDiscriminator from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PrimitiveString(BaseDiscriminator): """ @@ -37,53 +38,27 @@ class PrimitiveString(BaseDiscriminator): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PrimitiveString from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PrimitiveString from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_typeName": obj.get("_typeName"), - "_value": obj.get("_value") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py index 940016a86a72..135c6a6860b4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PropertyMap(BaseModel): """ @@ -37,64 +38,27 @@ class PropertyMap(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PropertyMap from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) - _field_dict = {} - if self.some_data: - for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - _dict['some_data'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PropertyMap from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "some_data": dict( - (_k, Tag.from_dict(_v)) - for _k, _v in obj["some_data"].items() - ) - if obj.get("some_data") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py index 0eb56422b648..1dca692c008d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PropertyNameCollision(BaseModel): """ @@ -38,54 +39,27 @@ class PropertyNameCollision(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PropertyNameCollision from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PropertyNameCollision from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_type": obj.get("_type"), - "type": obj.get("type"), - "type_": obj.get("type_") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py index c9f4fc6c0df9..174d6b75a6ad 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ReadOnlyFirst(BaseModel): """ @@ -37,55 +38,27 @@ class ReadOnlyFirst(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReadOnlyFirst from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - """ - excluded_fields: Set[str] = set([ - "bar", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReadOnlyFirst from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar"), - "baz": obj.get("baz") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py index 854749b4fb13..7017d2434765 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SecondCircularAllOfRef(BaseModel): """ @@ -37,61 +38,28 @@ class SecondCircularAllOfRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SecondCircularAllOfRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in circular_all_of_ref (list) - _items = [] - if self.circular_all_of_ref: - for _item_circular_all_of_ref in self.circular_all_of_ref: - if _item_circular_all_of_ref: - _items.append(_item_circular_all_of_ref.to_dict()) - _dict['circularAllOfRef'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SecondCircularAllOfRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name"), - "circularAllOfRef": [CircularAllOfRef.from_dict(_item) for _item in obj["circularAllOfRef"]] if obj.get("circularAllOfRef") is not None else None - }) - return _obj from petstore_api.models.circular_all_of_ref import CircularAllOfRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py index c6627cf0ba63..fb545192214a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SecondRef(BaseModel): """ @@ -37,57 +38,28 @@ class SecondRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SecondRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of circular_ref - if self.circular_ref: - _dict['circular_ref'] = self.circular_ref.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SecondRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "circular_ref": CircularReferenceModel.from_dict(obj["circular_ref"]) if obj.get("circular_ref") is not None else None - }) - return _obj from petstore_api.models.circular_reference_model import CircularReferenceModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py index 7c145db0d3ae..deabec983d4f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SelfReferenceModel(BaseModel): """ @@ -37,57 +38,28 @@ class SelfReferenceModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SelfReferenceModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested - if self.nested: - _dict['nested'] = self.nested.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SelfReferenceModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested": DummyModel.from_dict(obj["nested"]) if obj.get("nested") is not None else None - }) - return _obj from petstore_api.models.dummy_model import DummyModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py index 0336e24d17da..90861e4568ae 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SpecialModelName(BaseModel): """ @@ -36,52 +37,27 @@ class SpecialModelName(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SpecialModelName from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SpecialModelName from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "$special[property.name]": obj.get("$special[property.name]") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index d3c8f6185683..370785af0987 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.category import Category from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SpecialName(BaseModel): """ @@ -29,7 +30,10 @@ class SpecialName(BaseModel): """ # noqa: E501 var_property: Optional[StrictInt] = Field(default=None, alias="property") var_async: Optional[Category] = Field(default=None, alias="async") - var_schema: Optional[StrictStr] = Field(default=None, description="pet status in the store", alias="schema") + var_schema: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) __properties: ClassVar[List[str]] = ["property", "async", "schema"] @field_validator('var_schema') @@ -49,57 +53,27 @@ def var_schema_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SpecialName from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of var_async - if self.var_async: - _dict['async'] = self.var_async.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SpecialName from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "property": obj.get("property"), - "async": Category.from_dict(obj["async"]) if obj.get("async") is not None else None, - "schema": obj.get("schema") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py index e5ddcbcd4a74..575db976ade6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tag(BaseModel): """ @@ -37,53 +38,27 @@ class Tag(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tag from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tag from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py index 312b2c8ee473..18d6282e2c05 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py @@ -22,7 +22,8 @@ from uuid import UUID from petstore_api.models.task_activity import TaskActivity from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Task(BaseModel): """ @@ -39,56 +40,27 @@ class Task(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Task from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of activity - if self.activity: - _dict['activity'] = self.activity.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Task from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "activity": TaskActivity.from_dict(obj["activity"]) if obj.get("activity") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py index cc1e1fc5a60f..39a1c0bbc375 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py @@ -20,132 +20,55 @@ from petstore_api.models.bathing import Bathing from petstore_api.models.feeding import Feeding from petstore_api.models.poop_cleaning import PoopCleaning -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] -class TaskActivity(BaseModel): +class TaskActivity(RootModel[Union[Bathing, Feeding, PoopCleaning]]): """ TaskActivity """ - # data type: PoopCleaning - oneof_schema_1_validator: Optional[PoopCleaning] = None - # data type: Feeding - oneof_schema_2_validator: Optional[Feeding] = None - # data type: Bathing - oneof_schema_3_validator: Optional[Bathing] = None - actual_instance: Optional[Union[Bathing, Feeding, PoopCleaning]] = None - one_of_schemas: Set[str] = { "Bathing", "Feeding", "PoopCleaning" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[Bathing, Feeding, PoopCleaning] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = TaskActivity.model_construct() - error_messages = [] - match = 0 - # validate data type: PoopCleaning - if not isinstance(v, PoopCleaning): - error_messages.append(f"Error! Input type `{type(v)}` is not `PoopCleaning`") - else: - match += 1 - # validate data type: Feeding - if not isinstance(v, Feeding): - error_messages.append(f"Error! Input type `{type(v)}` is not `Feeding`") - else: - match += 1 - # validate data type: Bathing - if not isinstance(v, Bathing): - error_messages.append(f"Error! Input type `{type(v)}` is not `Bathing`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into PoopCleaning - try: - instance.actual_instance = PoopCleaning.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Feeding - try: - instance.actual_instance = Feeding.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Bathing - try: - instance.actual_instance = Bathing.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], Bathing, Feeding, PoopCleaning]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py index cba4ab845e5e..622dc55b5ecc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestErrorResponsesWithModel400Response(BaseModel): """ @@ -36,52 +37,27 @@ class TestErrorResponsesWithModel400Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel400Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "reason400": obj.get("reason400") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py index 787ca11942ab..ea5be0d8c54e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestErrorResponsesWithModel404Response(BaseModel): """ @@ -36,52 +37,27 @@ class TestErrorResponsesWithModel404Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel404Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "reason404": obj.get("reason404") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py index 7b93d84864f2..b8ae3f003698 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): """ @@ -37,64 +38,27 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "someProperty": obj.get("someProperty") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py index 218fa8f16d22..ac92886923bf 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py @@ -22,7 +22,8 @@ from petstore_api.models.test_enum import TestEnum from petstore_api.models.test_enum_with_default import TestEnumWithDefault from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestModelWithEnumDefault(BaseModel): """ @@ -32,7 +33,10 @@ class TestModelWithEnumDefault(BaseModel): test_string: Optional[StrictStr] = None test_enum_with_default: Optional[TestEnumWithDefault] = TestEnumWithDefault.ZWEI test_string_with_default: Optional[StrictStr] = 'ahoy matey' - test_inline_defined_enum_with_default: Optional[StrictStr] = 'B' + test_inline_defined_enum_with_default: Optional[Literal['A', 'B', 'C']] = Field( + None, + description="test_inline_defined_enum_with_default of the TestModelWithEnumDefault" + ) __properties: ClassVar[List[str]] = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"] @field_validator('test_inline_defined_enum_with_default') @@ -52,56 +56,27 @@ def test_inline_defined_enum_with_default_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestModelWithEnumDefault from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestModelWithEnumDefault from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "test_enum": obj.get("test_enum"), - "test_string": obj.get("test_string"), - "test_enum_with_default": obj.get("test_enum_with_default") if obj.get("test_enum_with_default") is not None else TestEnumWithDefault.ZWEI, - "test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey', - "test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B' - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py index a5c3bfdbb1b5..26432529a3c8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestObjectForMultipartRequestsRequestMarker(BaseModel): """ @@ -36,52 +37,27 @@ class TestObjectForMultipartRequestsRequestMarker(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestObjectForMultipartRequestsRequestMarker from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py index bf8cbf0596ae..3b2ffcf9d159 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tiger(BaseModel): """ @@ -36,52 +37,27 @@ class Tiger(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tiger from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tiger from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "skill": obj.get("skill") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index e50edf2efa85..07103b7095d6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UnnamedDictWithAdditionalModelListProperties(BaseModel): """ @@ -37,68 +38,27 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) - _field_dict_of_array = {} - if self.dict_property: - for _key_dict_property in self.dict_property: - if self.dict_property[_key_dict_property] is not None: - _field_dict_of_array[_key_dict_property] = [ - _item.to_dict() for _item in self.dict_property[_key_dict_property] - ] - _dict['dictProperty'] = _field_dict_of_array - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "dictProperty": dict( - (_k, - [CreatureInfo.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("dictProperty", {}).items() - ) - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 477dcae27c7c..cf92d499f17b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UnnamedDictWithAdditionalStringListProperties(BaseModel): """ @@ -36,52 +37,27 @@ class UnnamedDictWithAdditionalStringListProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "dictProperty": obj.get("dictProperty") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py index 9040618ac0d7..6d5c954aa65d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UploadFileWithAdditionalPropertiesRequestObject(BaseModel): """ @@ -36,52 +37,27 @@ class UploadFileWithAdditionalPropertiesRequestObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UploadFileWithAdditionalPropertiesRequestObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UploadFileWithAdditionalPropertiesRequestObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py index 45e0a66f89dd..5567c69c2c64 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class User(BaseModel): """ @@ -43,59 +44,27 @@ class User(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of User from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of User from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "username": obj.get("username"), - "firstName": obj.get("firstName"), - "lastName": obj.get("lastName"), - "email": obj.get("email"), - "password": obj.get("password"), - "phone": obj.get("phone"), - "userStatus": obj.get("userStatus") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py index f2cd8b7a3a30..7f800931c63b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py @@ -22,7 +22,8 @@ from petstore_api.models.one_of_enum_string import OneOfEnumString from petstore_api.models.pig import Pig from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class WithNestedOneOf(BaseModel): """ @@ -40,57 +41,27 @@ class WithNestedOneOf(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of WithNestedOneOf from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested_pig - if self.nested_pig: - _dict['nested_pig'] = self.nested_pig.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of WithNestedOneOf from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested_pig": Pig.from_dict(obj["nested_pig"]) if obj.get("nested_pig") is not None else None, - "nested_oneof_enum_string": obj.get("nested_oneof_enum_string") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesAnyType.md b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesAnyType.md index 314cba3a614c..b94c1e6d7d19 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesAnyType.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesAnyType.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_any_type import AdditionalPropert # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesAnyType from a JSON string -additional_properties_any_type_instance = AdditionalPropertiesAnyType.from_json(json) +additional_properties_any_type_instance = AdditionalPropertiesAnyType.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesAnyType.to_json()) +print(additional_properties_any_type_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_any_type_dict = additional_properties_any_type_instance.to_dict() +additional_properties_any_type_dict = additional_properties_any_type_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesAnyType from a dict -additional_properties_any_type_from_dict = AdditionalPropertiesAnyType.from_dict(additional_properties_any_type_dict) +additional_properties_any_type_from_dict = AdditionalPropertiesAnyType.model_validate(additional_properties_any_type_dict) ``` [[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-httpx/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesClass.md index 8d4c08707f55..4c880d6853e8 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesClass.md @@ -16,14 +16,14 @@ from petstore_api.models.additional_properties_class import AdditionalProperties # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesClass from a JSON string -additional_properties_class_instance = AdditionalPropertiesClass.from_json(json) +additional_properties_class_instance = AdditionalPropertiesClass.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesClass.to_json()) +print(additional_properties_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_class_dict = additional_properties_class_instance.to_dict() +additional_properties_class_dict = additional_properties_class_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesClass from a dict -additional_properties_class_from_dict = AdditionalPropertiesClass.from_dict(additional_properties_class_dict) +additional_properties_class_from_dict = AdditionalPropertiesClass.model_validate(additional_properties_class_dict) ``` [[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-httpx/docs/AdditionalPropertiesObject.md b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesObject.md index d647ec64896f..bf6743709338 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesObject.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesObject.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_object import AdditionalPropertie # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesObject from a JSON string -additional_properties_object_instance = AdditionalPropertiesObject.from_json(json) +additional_properties_object_instance = AdditionalPropertiesObject.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesObject.to_json()) +print(additional_properties_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_object_dict = additional_properties_object_instance.to_dict() +additional_properties_object_dict = additional_properties_object_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesObject from a dict -additional_properties_object_from_dict = AdditionalPropertiesObject.from_dict(additional_properties_object_dict) +additional_properties_object_from_dict = AdditionalPropertiesObject.model_validate(additional_properties_object_dict) ``` [[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-httpx/docs/AdditionalPropertiesWithDescriptionOnly.md b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesWithDescriptionOnly.md index 061f5524872b..1cb2a02f7584 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesWithDescriptionOnly.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/AdditionalPropertiesWithDescriptionOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_with_description_only import Addi # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string -additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.from_json(json) +additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesWithDescriptionOnly.to_json()) +print(additional_properties_with_description_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.to_dict() +additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesWithDescriptionOnly from a dict -additional_properties_with_description_only_from_dict = AdditionalPropertiesWithDescriptionOnly.from_dict(additional_properties_with_description_only_dict) +additional_properties_with_description_only_from_dict = AdditionalPropertiesWithDescriptionOnly.model_validate(additional_properties_with_description_only_dict) ``` [[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-httpx/docs/AllOfSuperModel.md b/samples/openapi3/client/petstore/python-httpx/docs/AllOfSuperModel.md index 421a1527f1ef..88cb95097517 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/AllOfSuperModel.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/AllOfSuperModel.md @@ -15,14 +15,14 @@ from petstore_api.models.all_of_super_model import AllOfSuperModel # TODO update the JSON string below json = "{}" # create an instance of AllOfSuperModel from a JSON string -all_of_super_model_instance = AllOfSuperModel.from_json(json) +all_of_super_model_instance = AllOfSuperModel.model_validate_json(json) # print the JSON string representation of the object -print(AllOfSuperModel.to_json()) +print(all_of_super_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -all_of_super_model_dict = all_of_super_model_instance.to_dict() +all_of_super_model_dict = all_of_super_model_instance.model_dump(by_alias=True) # create an instance of AllOfSuperModel from a dict -all_of_super_model_from_dict = AllOfSuperModel.from_dict(all_of_super_model_dict) +all_of_super_model_from_dict = AllOfSuperModel.model_validate(all_of_super_model_dict) ``` [[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-httpx/docs/AllOfWithSingleRef.md b/samples/openapi3/client/petstore/python-httpx/docs/AllOfWithSingleRef.md index 203a4b5da3d5..dd0f755dfe65 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/AllOfWithSingleRef.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/AllOfWithSingleRef.md @@ -16,14 +16,14 @@ from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef # TODO update the JSON string below json = "{}" # create an instance of AllOfWithSingleRef from a JSON string -all_of_with_single_ref_instance = AllOfWithSingleRef.from_json(json) +all_of_with_single_ref_instance = AllOfWithSingleRef.model_validate_json(json) # print the JSON string representation of the object -print(AllOfWithSingleRef.to_json()) +print(all_of_with_single_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -all_of_with_single_ref_dict = all_of_with_single_ref_instance.to_dict() +all_of_with_single_ref_dict = all_of_with_single_ref_instance.model_dump(by_alias=True) # create an instance of AllOfWithSingleRef from a dict -all_of_with_single_ref_from_dict = AllOfWithSingleRef.from_dict(all_of_with_single_ref_dict) +all_of_with_single_ref_from_dict = AllOfWithSingleRef.model_validate(all_of_with_single_ref_dict) ``` [[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-httpx/docs/Animal.md b/samples/openapi3/client/petstore/python-httpx/docs/Animal.md index 381d27b66e44..fcded75f52be 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Animal.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Animal.md @@ -16,14 +16,14 @@ from petstore_api.models.animal import Animal # TODO update the JSON string below json = "{}" # create an instance of Animal from a JSON string -animal_instance = Animal.from_json(json) +animal_instance = Animal.model_validate_json(json) # print the JSON string representation of the object -print(Animal.to_json()) +print(animal_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -animal_dict = animal_instance.to_dict() +animal_dict = animal_instance.model_dump(by_alias=True) # create an instance of Animal from a dict -animal_from_dict = Animal.from_dict(animal_dict) +animal_from_dict = Animal.model_validate(animal_dict) ``` [[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-httpx/docs/AnyOfColor.md b/samples/openapi3/client/petstore/python-httpx/docs/AnyOfColor.md index 6ed75dd7b48a..02aab883b2b0 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/AnyOfColor.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/AnyOfColor.md @@ -15,14 +15,14 @@ from petstore_api.models.any_of_color import AnyOfColor # TODO update the JSON string below json = "{}" # create an instance of AnyOfColor from a JSON string -any_of_color_instance = AnyOfColor.from_json(json) +any_of_color_instance = AnyOfColor.model_validate_json(json) # print the JSON string representation of the object -print(AnyOfColor.to_json()) +print(any_of_color_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -any_of_color_dict = any_of_color_instance.to_dict() +any_of_color_dict = any_of_color_instance.model_dump(by_alias=True) # create an instance of AnyOfColor from a dict -any_of_color_from_dict = AnyOfColor.from_dict(any_of_color_dict) +any_of_color_from_dict = AnyOfColor.model_validate(any_of_color_dict) ``` [[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-httpx/docs/AnyOfPig.md b/samples/openapi3/client/petstore/python-httpx/docs/AnyOfPig.md index 9367e2261898..db2878121f29 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/AnyOfPig.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/AnyOfPig.md @@ -17,14 +17,14 @@ from petstore_api.models.any_of_pig import AnyOfPig # TODO update the JSON string below json = "{}" # create an instance of AnyOfPig from a JSON string -any_of_pig_instance = AnyOfPig.from_json(json) +any_of_pig_instance = AnyOfPig.model_validate_json(json) # print the JSON string representation of the object -print(AnyOfPig.to_json()) +print(any_of_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -any_of_pig_dict = any_of_pig_instance.to_dict() +any_of_pig_dict = any_of_pig_instance.model_dump(by_alias=True) # create an instance of AnyOfPig from a dict -any_of_pig_from_dict = AnyOfPig.from_dict(any_of_pig_dict) +any_of_pig_from_dict = AnyOfPig.model_validate(any_of_pig_dict) ``` [[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-httpx/docs/ArrayOfArrayOfModel.md b/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfArrayOfModel.md index f866863d53f9..e8274d8fbb52 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfArrayOfModel.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfArrayOfModel.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel # TODO update the JSON string below json = "{}" # create an instance of ArrayOfArrayOfModel from a JSON string -array_of_array_of_model_instance = ArrayOfArrayOfModel.from_json(json) +array_of_array_of_model_instance = ArrayOfArrayOfModel.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfArrayOfModel.to_json()) +print(array_of_array_of_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_array_of_model_dict = array_of_array_of_model_instance.to_dict() +array_of_array_of_model_dict = array_of_array_of_model_instance.model_dump(by_alias=True) # create an instance of ArrayOfArrayOfModel from a dict -array_of_array_of_model_from_dict = ArrayOfArrayOfModel.from_dict(array_of_array_of_model_dict) +array_of_array_of_model_from_dict = ArrayOfArrayOfModel.model_validate(array_of_array_of_model_dict) ``` [[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-httpx/docs/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfArrayOfNumberOnly.md index 32bd2dfbf1e2..8931a1c7e467 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfArrayOfNumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb # TODO update the JSON string below json = "{}" # create an instance of ArrayOfArrayOfNumberOnly from a JSON string -array_of_array_of_number_only_instance = ArrayOfArrayOfNumberOnly.from_json(json) +array_of_array_of_number_only_instance = ArrayOfArrayOfNumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfArrayOfNumberOnly.to_json()) +print(array_of_array_of_number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_array_of_number_only_dict = array_of_array_of_number_only_instance.to_dict() +array_of_array_of_number_only_dict = array_of_array_of_number_only_instance.model_dump(by_alias=True) # create an instance of ArrayOfArrayOfNumberOnly from a dict -array_of_array_of_number_only_from_dict = ArrayOfArrayOfNumberOnly.from_dict(array_of_array_of_number_only_dict) +array_of_array_of_number_only_from_dict = ArrayOfArrayOfNumberOnly.model_validate(array_of_array_of_number_only_dict) ``` [[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-httpx/docs/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfNumberOnly.md index b814d7594942..a709583be699 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ArrayOfNumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_number_only import ArrayOfNumberOnly # TODO update the JSON string below json = "{}" # create an instance of ArrayOfNumberOnly from a JSON string -array_of_number_only_instance = ArrayOfNumberOnly.from_json(json) +array_of_number_only_instance = ArrayOfNumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfNumberOnly.to_json()) +print(array_of_number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_number_only_dict = array_of_number_only_instance.to_dict() +array_of_number_only_dict = array_of_number_only_instance.model_dump(by_alias=True) # create an instance of ArrayOfNumberOnly from a dict -array_of_number_only_from_dict = ArrayOfNumberOnly.from_dict(array_of_number_only_dict) +array_of_number_only_from_dict = ArrayOfNumberOnly.model_validate(array_of_number_only_dict) ``` [[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-httpx/docs/ArrayTest.md b/samples/openapi3/client/petstore/python-httpx/docs/ArrayTest.md index ed871fae662d..a99eb056c5ca 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ArrayTest.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ArrayTest.md @@ -18,14 +18,14 @@ from petstore_api.models.array_test import ArrayTest # TODO update the JSON string below json = "{}" # create an instance of ArrayTest from a JSON string -array_test_instance = ArrayTest.from_json(json) +array_test_instance = ArrayTest.model_validate_json(json) # print the JSON string representation of the object -print(ArrayTest.to_json()) +print(array_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_test_dict = array_test_instance.to_dict() +array_test_dict = array_test_instance.model_dump(by_alias=True) # create an instance of ArrayTest from a dict -array_test_from_dict = ArrayTest.from_dict(array_test_dict) +array_test_from_dict = ArrayTest.model_validate(array_test_dict) ``` [[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-httpx/docs/BaseDiscriminator.md b/samples/openapi3/client/petstore/python-httpx/docs/BaseDiscriminator.md index fcdbeb032e68..0482396cbcf8 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/BaseDiscriminator.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/BaseDiscriminator.md @@ -15,14 +15,14 @@ from petstore_api.models.base_discriminator import BaseDiscriminator # TODO update the JSON string below json = "{}" # create an instance of BaseDiscriminator from a JSON string -base_discriminator_instance = BaseDiscriminator.from_json(json) +base_discriminator_instance = BaseDiscriminator.model_validate_json(json) # print the JSON string representation of the object -print(BaseDiscriminator.to_json()) +print(base_discriminator_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -base_discriminator_dict = base_discriminator_instance.to_dict() +base_discriminator_dict = base_discriminator_instance.model_dump(by_alias=True) # create an instance of BaseDiscriminator from a dict -base_discriminator_from_dict = BaseDiscriminator.from_dict(base_discriminator_dict) +base_discriminator_from_dict = BaseDiscriminator.model_validate(base_discriminator_dict) ``` [[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-httpx/docs/BasquePig.md b/samples/openapi3/client/petstore/python-httpx/docs/BasquePig.md index ee28d628722f..9844d05b3740 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/BasquePig.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/BasquePig.md @@ -16,14 +16,14 @@ from petstore_api.models.basque_pig import BasquePig # TODO update the JSON string below json = "{}" # create an instance of BasquePig from a JSON string -basque_pig_instance = BasquePig.from_json(json) +basque_pig_instance = BasquePig.model_validate_json(json) # print the JSON string representation of the object -print(BasquePig.to_json()) +print(basque_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -basque_pig_dict = basque_pig_instance.to_dict() +basque_pig_dict = basque_pig_instance.model_dump(by_alias=True) # create an instance of BasquePig from a dict -basque_pig_from_dict = BasquePig.from_dict(basque_pig_dict) +basque_pig_from_dict = BasquePig.model_validate(basque_pig_dict) ``` [[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-httpx/docs/Bathing.md b/samples/openapi3/client/petstore/python-httpx/docs/Bathing.md index 6ad70e2f67cc..2c8d8332629b 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Bathing.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Bathing.md @@ -17,14 +17,14 @@ from petstore_api.models.bathing import Bathing # TODO update the JSON string below json = "{}" # create an instance of Bathing from a JSON string -bathing_instance = Bathing.from_json(json) +bathing_instance = Bathing.model_validate_json(json) # print the JSON string representation of the object -print(Bathing.to_json()) +print(bathing_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -bathing_dict = bathing_instance.to_dict() +bathing_dict = bathing_instance.model_dump(by_alias=True) # create an instance of Bathing from a dict -bathing_from_dict = Bathing.from_dict(bathing_dict) +bathing_from_dict = Bathing.model_validate(bathing_dict) ``` [[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-httpx/docs/Capitalization.md b/samples/openapi3/client/petstore/python-httpx/docs/Capitalization.md index 6f564a8ed8c9..55fcc0c01cb2 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Capitalization.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Capitalization.md @@ -20,14 +20,14 @@ from petstore_api.models.capitalization import Capitalization # TODO update the JSON string below json = "{}" # create an instance of Capitalization from a JSON string -capitalization_instance = Capitalization.from_json(json) +capitalization_instance = Capitalization.model_validate_json(json) # print the JSON string representation of the object -print(Capitalization.to_json()) +print(capitalization_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -capitalization_dict = capitalization_instance.to_dict() +capitalization_dict = capitalization_instance.model_dump(by_alias=True) # create an instance of Capitalization from a dict -capitalization_from_dict = Capitalization.from_dict(capitalization_dict) +capitalization_from_dict = Capitalization.model_validate(capitalization_dict) ``` [[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-httpx/docs/Cat.md b/samples/openapi3/client/petstore/python-httpx/docs/Cat.md index d0e39efdb33e..0845d68bd487 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Cat.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Cat.md @@ -15,14 +15,14 @@ from petstore_api.models.cat import Cat # TODO update the JSON string below json = "{}" # create an instance of Cat from a JSON string -cat_instance = Cat.from_json(json) +cat_instance = Cat.model_validate_json(json) # print the JSON string representation of the object -print(Cat.to_json()) +print(cat_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -cat_dict = cat_instance.to_dict() +cat_dict = cat_instance.model_dump(by_alias=True) # create an instance of Cat from a dict -cat_from_dict = Cat.from_dict(cat_dict) +cat_from_dict = Cat.model_validate(cat_dict) ``` [[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-httpx/docs/Category.md b/samples/openapi3/client/petstore/python-httpx/docs/Category.md index dbde14b7344c..8a14791c7925 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Category.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Category.md @@ -16,14 +16,14 @@ from petstore_api.models.category import Category # TODO update the JSON string below json = "{}" # create an instance of Category from a JSON string -category_instance = Category.from_json(json) +category_instance = Category.model_validate_json(json) # print the JSON string representation of the object -print(Category.to_json()) +print(category_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -category_dict = category_instance.to_dict() +category_dict = category_instance.model_dump(by_alias=True) # create an instance of Category from a dict -category_from_dict = Category.from_dict(category_dict) +category_from_dict = Category.model_validate(category_dict) ``` [[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-httpx/docs/CircularAllOfRef.md b/samples/openapi3/client/petstore/python-httpx/docs/CircularAllOfRef.md index 65b171177e58..f937a53cfe3c 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/CircularAllOfRef.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/CircularAllOfRef.md @@ -16,14 +16,14 @@ from petstore_api.models.circular_all_of_ref import CircularAllOfRef # TODO update the JSON string below json = "{}" # create an instance of CircularAllOfRef from a JSON string -circular_all_of_ref_instance = CircularAllOfRef.from_json(json) +circular_all_of_ref_instance = CircularAllOfRef.model_validate_json(json) # print the JSON string representation of the object -print(CircularAllOfRef.to_json()) +print(circular_all_of_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -circular_all_of_ref_dict = circular_all_of_ref_instance.to_dict() +circular_all_of_ref_dict = circular_all_of_ref_instance.model_dump(by_alias=True) # create an instance of CircularAllOfRef from a dict -circular_all_of_ref_from_dict = CircularAllOfRef.from_dict(circular_all_of_ref_dict) +circular_all_of_ref_from_dict = CircularAllOfRef.model_validate(circular_all_of_ref_dict) ``` [[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-httpx/docs/CircularReferenceModel.md b/samples/openapi3/client/petstore/python-httpx/docs/CircularReferenceModel.md index 87216f7273ab..9a39f46e5d7d 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/CircularReferenceModel.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/CircularReferenceModel.md @@ -16,14 +16,14 @@ from petstore_api.models.circular_reference_model import CircularReferenceModel # TODO update the JSON string below json = "{}" # create an instance of CircularReferenceModel from a JSON string -circular_reference_model_instance = CircularReferenceModel.from_json(json) +circular_reference_model_instance = CircularReferenceModel.model_validate_json(json) # print the JSON string representation of the object -print(CircularReferenceModel.to_json()) +print(circular_reference_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -circular_reference_model_dict = circular_reference_model_instance.to_dict() +circular_reference_model_dict = circular_reference_model_instance.model_dump(by_alias=True) # create an instance of CircularReferenceModel from a dict -circular_reference_model_from_dict = CircularReferenceModel.from_dict(circular_reference_model_dict) +circular_reference_model_from_dict = CircularReferenceModel.model_validate(circular_reference_model_dict) ``` [[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-httpx/docs/ClassModel.md b/samples/openapi3/client/petstore/python-httpx/docs/ClassModel.md index ea76a5c157bf..50fbfefa7661 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ClassModel.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ClassModel.md @@ -16,14 +16,14 @@ from petstore_api.models.class_model import ClassModel # TODO update the JSON string below json = "{}" # create an instance of ClassModel from a JSON string -class_model_instance = ClassModel.from_json(json) +class_model_instance = ClassModel.model_validate_json(json) # print the JSON string representation of the object -print(ClassModel.to_json()) +print(class_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -class_model_dict = class_model_instance.to_dict() +class_model_dict = class_model_instance.model_dump(by_alias=True) # create an instance of ClassModel from a dict -class_model_from_dict = ClassModel.from_dict(class_model_dict) +class_model_from_dict = ClassModel.model_validate(class_model_dict) ``` [[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-httpx/docs/Client.md b/samples/openapi3/client/petstore/python-httpx/docs/Client.md index 22321c189150..160a80da457f 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Client.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Client.md @@ -15,14 +15,14 @@ from petstore_api.models.client import Client # TODO update the JSON string below json = "{}" # create an instance of Client from a JSON string -client_instance = Client.from_json(json) +client_instance = Client.model_validate_json(json) # print the JSON string representation of the object -print(Client.to_json()) +print(client_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -client_dict = client_instance.to_dict() +client_dict = client_instance.model_dump(by_alias=True) # create an instance of Client from a dict -client_from_dict = Client.from_dict(client_dict) +client_from_dict = Client.model_validate(client_dict) ``` [[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-httpx/docs/Color.md b/samples/openapi3/client/petstore/python-httpx/docs/Color.md index 9ac3ab2e91f4..1425ff185040 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Color.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Color.md @@ -15,14 +15,14 @@ from petstore_api.models.color import Color # TODO update the JSON string below json = "{}" # create an instance of Color from a JSON string -color_instance = Color.from_json(json) +color_instance = Color.model_validate_json(json) # print the JSON string representation of the object -print(Color.to_json()) +print(color_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -color_dict = color_instance.to_dict() +color_dict = color_instance.model_dump(by_alias=True) # create an instance of Color from a dict -color_from_dict = Color.from_dict(color_dict) +color_from_dict = Color.model_validate(color_dict) ``` [[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-httpx/docs/Creature.md b/samples/openapi3/client/petstore/python-httpx/docs/Creature.md index a4710214c198..eb0ba3b2f127 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Creature.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Creature.md @@ -16,14 +16,14 @@ from petstore_api.models.creature import Creature # TODO update the JSON string below json = "{}" # create an instance of Creature from a JSON string -creature_instance = Creature.from_json(json) +creature_instance = Creature.model_validate_json(json) # print the JSON string representation of the object -print(Creature.to_json()) +print(creature_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -creature_dict = creature_instance.to_dict() +creature_dict = creature_instance.model_dump(by_alias=True) # create an instance of Creature from a dict -creature_from_dict = Creature.from_dict(creature_dict) +creature_from_dict = Creature.model_validate(creature_dict) ``` [[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-httpx/docs/CreatureInfo.md b/samples/openapi3/client/petstore/python-httpx/docs/CreatureInfo.md index db3b82bb9ff5..156d93939201 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/CreatureInfo.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/CreatureInfo.md @@ -15,14 +15,14 @@ from petstore_api.models.creature_info import CreatureInfo # TODO update the JSON string below json = "{}" # create an instance of CreatureInfo from a JSON string -creature_info_instance = CreatureInfo.from_json(json) +creature_info_instance = CreatureInfo.model_validate_json(json) # print the JSON string representation of the object -print(CreatureInfo.to_json()) +print(creature_info_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -creature_info_dict = creature_info_instance.to_dict() +creature_info_dict = creature_info_instance.model_dump(by_alias=True) # create an instance of CreatureInfo from a dict -creature_info_from_dict = CreatureInfo.from_dict(creature_info_dict) +creature_info_from_dict = CreatureInfo.model_validate(creature_info_dict) ``` [[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-httpx/docs/DanishPig.md b/samples/openapi3/client/petstore/python-httpx/docs/DanishPig.md index 16941388832a..5eac27f79e79 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/DanishPig.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/DanishPig.md @@ -16,14 +16,14 @@ from petstore_api.models.danish_pig import DanishPig # TODO update the JSON string below json = "{}" # create an instance of DanishPig from a JSON string -danish_pig_instance = DanishPig.from_json(json) +danish_pig_instance = DanishPig.model_validate_json(json) # print the JSON string representation of the object -print(DanishPig.to_json()) +print(danish_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -danish_pig_dict = danish_pig_instance.to_dict() +danish_pig_dict = danish_pig_instance.model_dump(by_alias=True) # create an instance of DanishPig from a dict -danish_pig_from_dict = DanishPig.from_dict(danish_pig_dict) +danish_pig_from_dict = DanishPig.model_validate(danish_pig_dict) ``` [[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-httpx/docs/DeprecatedObject.md b/samples/openapi3/client/petstore/python-httpx/docs/DeprecatedObject.md index 6b362f379ba4..ff3aa9812e2d 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/DeprecatedObject.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/DeprecatedObject.md @@ -15,14 +15,14 @@ from petstore_api.models.deprecated_object import DeprecatedObject # TODO update the JSON string below json = "{}" # create an instance of DeprecatedObject from a JSON string -deprecated_object_instance = DeprecatedObject.from_json(json) +deprecated_object_instance = DeprecatedObject.model_validate_json(json) # print the JSON string representation of the object -print(DeprecatedObject.to_json()) +print(deprecated_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -deprecated_object_dict = deprecated_object_instance.to_dict() +deprecated_object_dict = deprecated_object_instance.model_dump(by_alias=True) # create an instance of DeprecatedObject from a dict -deprecated_object_from_dict = DeprecatedObject.from_dict(deprecated_object_dict) +deprecated_object_from_dict = DeprecatedObject.model_validate(deprecated_object_dict) ``` [[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-httpx/docs/DiscriminatorAllOfSub.md b/samples/openapi3/client/petstore/python-httpx/docs/DiscriminatorAllOfSub.md index f72b6e8e68ca..aa7af45b99fa 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/DiscriminatorAllOfSub.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/DiscriminatorAllOfSub.md @@ -14,14 +14,14 @@ from petstore_api.models.discriminator_all_of_sub import DiscriminatorAllOfSub # TODO update the JSON string below json = "{}" # create an instance of DiscriminatorAllOfSub from a JSON string -discriminator_all_of_sub_instance = DiscriminatorAllOfSub.from_json(json) +discriminator_all_of_sub_instance = DiscriminatorAllOfSub.model_validate_json(json) # print the JSON string representation of the object -print(DiscriminatorAllOfSub.to_json()) +print(discriminator_all_of_sub_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -discriminator_all_of_sub_dict = discriminator_all_of_sub_instance.to_dict() +discriminator_all_of_sub_dict = discriminator_all_of_sub_instance.model_dump(by_alias=True) # create an instance of DiscriminatorAllOfSub from a dict -discriminator_all_of_sub_from_dict = DiscriminatorAllOfSub.from_dict(discriminator_all_of_sub_dict) +discriminator_all_of_sub_from_dict = DiscriminatorAllOfSub.model_validate(discriminator_all_of_sub_dict) ``` [[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-httpx/docs/DiscriminatorAllOfSuper.md b/samples/openapi3/client/petstore/python-httpx/docs/DiscriminatorAllOfSuper.md index 477c05bfc446..c21e5b2296ac 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/DiscriminatorAllOfSuper.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/DiscriminatorAllOfSuper.md @@ -15,14 +15,14 @@ from petstore_api.models.discriminator_all_of_super import DiscriminatorAllOfSup # TODO update the JSON string below json = "{}" # create an instance of DiscriminatorAllOfSuper from a JSON string -discriminator_all_of_super_instance = DiscriminatorAllOfSuper.from_json(json) +discriminator_all_of_super_instance = DiscriminatorAllOfSuper.model_validate_json(json) # print the JSON string representation of the object -print(DiscriminatorAllOfSuper.to_json()) +print(discriminator_all_of_super_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -discriminator_all_of_super_dict = discriminator_all_of_super_instance.to_dict() +discriminator_all_of_super_dict = discriminator_all_of_super_instance.model_dump(by_alias=True) # create an instance of DiscriminatorAllOfSuper from a dict -discriminator_all_of_super_from_dict = DiscriminatorAllOfSuper.from_dict(discriminator_all_of_super_dict) +discriminator_all_of_super_from_dict = DiscriminatorAllOfSuper.model_validate(discriminator_all_of_super_dict) ``` [[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-httpx/docs/Dog.md b/samples/openapi3/client/petstore/python-httpx/docs/Dog.md index ed23f613d01d..2065d42f5f6b 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Dog.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Dog.md @@ -15,14 +15,14 @@ from petstore_api.models.dog import Dog # TODO update the JSON string below json = "{}" # create an instance of Dog from a JSON string -dog_instance = Dog.from_json(json) +dog_instance = Dog.model_validate_json(json) # print the JSON string representation of the object -print(Dog.to_json()) +print(dog_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -dog_dict = dog_instance.to_dict() +dog_dict = dog_instance.model_dump(by_alias=True) # create an instance of Dog from a dict -dog_from_dict = Dog.from_dict(dog_dict) +dog_from_dict = Dog.model_validate(dog_dict) ``` [[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-httpx/docs/DummyModel.md b/samples/openapi3/client/petstore/python-httpx/docs/DummyModel.md index 01b675977f58..dfe28d9f75b1 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/DummyModel.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/DummyModel.md @@ -16,14 +16,14 @@ from petstore_api.models.dummy_model import DummyModel # TODO update the JSON string below json = "{}" # create an instance of DummyModel from a JSON string -dummy_model_instance = DummyModel.from_json(json) +dummy_model_instance = DummyModel.model_validate_json(json) # print the JSON string representation of the object -print(DummyModel.to_json()) +print(dummy_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -dummy_model_dict = dummy_model_instance.to_dict() +dummy_model_dict = dummy_model_instance.model_dump(by_alias=True) # create an instance of DummyModel from a dict -dummy_model_from_dict = DummyModel.from_dict(dummy_model_dict) +dummy_model_from_dict = DummyModel.model_validate(dummy_model_dict) ``` [[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-httpx/docs/EnumArrays.md b/samples/openapi3/client/petstore/python-httpx/docs/EnumArrays.md index f44617497bce..bf8b1a6cd05c 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/EnumArrays.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/EnumArrays.md @@ -16,14 +16,14 @@ from petstore_api.models.enum_arrays import EnumArrays # TODO update the JSON string below json = "{}" # create an instance of EnumArrays from a JSON string -enum_arrays_instance = EnumArrays.from_json(json) +enum_arrays_instance = EnumArrays.model_validate_json(json) # print the JSON string representation of the object -print(EnumArrays.to_json()) +print(enum_arrays_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_arrays_dict = enum_arrays_instance.to_dict() +enum_arrays_dict = enum_arrays_instance.model_dump(by_alias=True) # create an instance of EnumArrays from a dict -enum_arrays_from_dict = EnumArrays.from_dict(enum_arrays_dict) +enum_arrays_from_dict = EnumArrays.model_validate(enum_arrays_dict) ``` [[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-httpx/docs/EnumRefWithDefaultValue.md b/samples/openapi3/client/petstore/python-httpx/docs/EnumRefWithDefaultValue.md index eeb0dc66969f..cbe6845479eb 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/EnumRefWithDefaultValue.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/EnumRefWithDefaultValue.md @@ -15,14 +15,14 @@ from petstore_api.models.enum_ref_with_default_value import EnumRefWithDefaultVa # TODO update the JSON string below json = "{}" # create an instance of EnumRefWithDefaultValue from a JSON string -enum_ref_with_default_value_instance = EnumRefWithDefaultValue.from_json(json) +enum_ref_with_default_value_instance = EnumRefWithDefaultValue.model_validate_json(json) # print the JSON string representation of the object -print(EnumRefWithDefaultValue.to_json()) +print(enum_ref_with_default_value_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_ref_with_default_value_dict = enum_ref_with_default_value_instance.to_dict() +enum_ref_with_default_value_dict = enum_ref_with_default_value_instance.model_dump(by_alias=True) # create an instance of EnumRefWithDefaultValue from a dict -enum_ref_with_default_value_from_dict = EnumRefWithDefaultValue.from_dict(enum_ref_with_default_value_dict) +enum_ref_with_default_value_from_dict = EnumRefWithDefaultValue.model_validate(enum_ref_with_default_value_dict) ``` [[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-httpx/docs/EnumTest.md b/samples/openapi3/client/petstore/python-httpx/docs/EnumTest.md index 9f96c605d888..6ce4891aa9d5 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/EnumTest.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/EnumTest.md @@ -27,14 +27,14 @@ from petstore_api.models.enum_test import EnumTest # TODO update the JSON string below json = "{}" # create an instance of EnumTest from a JSON string -enum_test_instance = EnumTest.from_json(json) +enum_test_instance = EnumTest.model_validate_json(json) # print the JSON string representation of the object -print(EnumTest.to_json()) +print(enum_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_test_dict = enum_test_instance.to_dict() +enum_test_dict = enum_test_instance.model_dump(by_alias=True) # create an instance of EnumTest from a dict -enum_test_from_dict = EnumTest.from_dict(enum_test_dict) +enum_test_from_dict = EnumTest.model_validate(enum_test_dict) ``` [[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-httpx/docs/Feeding.md b/samples/openapi3/client/petstore/python-httpx/docs/Feeding.md index 9f92b5d964d3..773d1373cca0 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Feeding.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Feeding.md @@ -17,14 +17,14 @@ from petstore_api.models.feeding import Feeding # TODO update the JSON string below json = "{}" # create an instance of Feeding from a JSON string -feeding_instance = Feeding.from_json(json) +feeding_instance = Feeding.model_validate_json(json) # print the JSON string representation of the object -print(Feeding.to_json()) +print(feeding_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -feeding_dict = feeding_instance.to_dict() +feeding_dict = feeding_instance.model_dump(by_alias=True) # create an instance of Feeding from a dict -feeding_from_dict = Feeding.from_dict(feeding_dict) +feeding_from_dict = Feeding.model_validate(feeding_dict) ``` [[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-httpx/docs/File.md b/samples/openapi3/client/petstore/python-httpx/docs/File.md index 23f0567411ce..3fe748f4f30f 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/File.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/File.md @@ -16,14 +16,14 @@ from petstore_api.models.file import File # TODO update the JSON string below json = "{}" # create an instance of File from a JSON string -file_instance = File.from_json(json) +file_instance = File.model_validate_json(json) # print the JSON string representation of the object -print(File.to_json()) +print(file_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -file_dict = file_instance.to_dict() +file_dict = file_instance.model_dump(by_alias=True) # create an instance of File from a dict -file_from_dict = File.from_dict(file_dict) +file_from_dict = File.model_validate(file_dict) ``` [[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-httpx/docs/FileSchemaTestClass.md b/samples/openapi3/client/petstore/python-httpx/docs/FileSchemaTestClass.md index e1118042a8ec..78bc4ae135da 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/FileSchemaTestClass.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/FileSchemaTestClass.md @@ -16,14 +16,14 @@ from petstore_api.models.file_schema_test_class import FileSchemaTestClass # TODO update the JSON string below json = "{}" # create an instance of FileSchemaTestClass from a JSON string -file_schema_test_class_instance = FileSchemaTestClass.from_json(json) +file_schema_test_class_instance = FileSchemaTestClass.model_validate_json(json) # print the JSON string representation of the object -print(FileSchemaTestClass.to_json()) +print(file_schema_test_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -file_schema_test_class_dict = file_schema_test_class_instance.to_dict() +file_schema_test_class_dict = file_schema_test_class_instance.model_dump(by_alias=True) # create an instance of FileSchemaTestClass from a dict -file_schema_test_class_from_dict = FileSchemaTestClass.from_dict(file_schema_test_class_dict) +file_schema_test_class_from_dict = FileSchemaTestClass.model_validate(file_schema_test_class_dict) ``` [[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-httpx/docs/FirstRef.md b/samples/openapi3/client/petstore/python-httpx/docs/FirstRef.md index 94b8ddc5ac22..6da6650e5df7 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/FirstRef.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/FirstRef.md @@ -16,14 +16,14 @@ from petstore_api.models.first_ref import FirstRef # TODO update the JSON string below json = "{}" # create an instance of FirstRef from a JSON string -first_ref_instance = FirstRef.from_json(json) +first_ref_instance = FirstRef.model_validate_json(json) # print the JSON string representation of the object -print(FirstRef.to_json()) +print(first_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -first_ref_dict = first_ref_instance.to_dict() +first_ref_dict = first_ref_instance.model_dump(by_alias=True) # create an instance of FirstRef from a dict -first_ref_from_dict = FirstRef.from_dict(first_ref_dict) +first_ref_from_dict = FirstRef.model_validate(first_ref_dict) ``` [[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-httpx/docs/Foo.md b/samples/openapi3/client/petstore/python-httpx/docs/Foo.md index f635b0daa6db..c11ae111ee22 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Foo.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Foo.md @@ -15,14 +15,14 @@ from petstore_api.models.foo import Foo # TODO update the JSON string below json = "{}" # create an instance of Foo from a JSON string -foo_instance = Foo.from_json(json) +foo_instance = Foo.model_validate_json(json) # print the JSON string representation of the object -print(Foo.to_json()) +print(foo_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -foo_dict = foo_instance.to_dict() +foo_dict = foo_instance.model_dump(by_alias=True) # create an instance of Foo from a dict -foo_from_dict = Foo.from_dict(foo_dict) +foo_from_dict = Foo.model_validate(foo_dict) ``` [[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-httpx/docs/FooGetDefaultResponse.md b/samples/openapi3/client/petstore/python-httpx/docs/FooGetDefaultResponse.md index 8d84f795b00a..aaccf08bfd2e 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/FooGetDefaultResponse.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/FooGetDefaultResponse.md @@ -15,14 +15,14 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse # TODO update the JSON string below json = "{}" # create an instance of FooGetDefaultResponse from a JSON string -foo_get_default_response_instance = FooGetDefaultResponse.from_json(json) +foo_get_default_response_instance = FooGetDefaultResponse.model_validate_json(json) # print the JSON string representation of the object -print(FooGetDefaultResponse.to_json()) +print(foo_get_default_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -foo_get_default_response_dict = foo_get_default_response_instance.to_dict() +foo_get_default_response_dict = foo_get_default_response_instance.model_dump(by_alias=True) # create an instance of FooGetDefaultResponse from a dict -foo_get_default_response_from_dict = FooGetDefaultResponse.from_dict(foo_get_default_response_dict) +foo_get_default_response_from_dict = FooGetDefaultResponse.model_validate(foo_get_default_response_dict) ``` [[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-httpx/docs/FormatTest.md b/samples/openapi3/client/petstore/python-httpx/docs/FormatTest.md index 714d2401bbae..98c3dc89570d 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/FormatTest.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/FormatTest.md @@ -31,14 +31,14 @@ from petstore_api.models.format_test import FormatTest # TODO update the JSON string below json = "{}" # create an instance of FormatTest from a JSON string -format_test_instance = FormatTest.from_json(json) +format_test_instance = FormatTest.model_validate_json(json) # print the JSON string representation of the object -print(FormatTest.to_json()) +print(format_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -format_test_dict = format_test_instance.to_dict() +format_test_dict = format_test_instance.model_dump(by_alias=True) # create an instance of FormatTest from a dict -format_test_from_dict = FormatTest.from_dict(format_test_dict) +format_test_from_dict = FormatTest.model_validate(format_test_dict) ``` [[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-httpx/docs/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/python-httpx/docs/HasOnlyReadOnly.md index fdc48781b15a..66dca11251aa 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/HasOnlyReadOnly.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/HasOnlyReadOnly.md @@ -16,14 +16,14 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly # TODO update the JSON string below json = "{}" # create an instance of HasOnlyReadOnly from a JSON string -has_only_read_only_instance = HasOnlyReadOnly.from_json(json) +has_only_read_only_instance = HasOnlyReadOnly.model_validate_json(json) # print the JSON string representation of the object -print(HasOnlyReadOnly.to_json()) +print(has_only_read_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -has_only_read_only_dict = has_only_read_only_instance.to_dict() +has_only_read_only_dict = has_only_read_only_instance.model_dump(by_alias=True) # create an instance of HasOnlyReadOnly from a dict -has_only_read_only_from_dict = HasOnlyReadOnly.from_dict(has_only_read_only_dict) +has_only_read_only_from_dict = HasOnlyReadOnly.model_validate(has_only_read_only_dict) ``` [[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-httpx/docs/HealthCheckResult.md b/samples/openapi3/client/petstore/python-httpx/docs/HealthCheckResult.md index d4a2b187167f..522156ae5b16 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/HealthCheckResult.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/HealthCheckResult.md @@ -16,14 +16,14 @@ from petstore_api.models.health_check_result import HealthCheckResult # TODO update the JSON string below json = "{}" # create an instance of HealthCheckResult from a JSON string -health_check_result_instance = HealthCheckResult.from_json(json) +health_check_result_instance = HealthCheckResult.model_validate_json(json) # print the JSON string representation of the object -print(HealthCheckResult.to_json()) +print(health_check_result_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -health_check_result_dict = health_check_result_instance.to_dict() +health_check_result_dict = health_check_result_instance.model_dump(by_alias=True) # create an instance of HealthCheckResult from a dict -health_check_result_from_dict = HealthCheckResult.from_dict(health_check_result_dict) +health_check_result_from_dict = HealthCheckResult.model_validate(health_check_result_dict) ``` [[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-httpx/docs/HuntingDog.md b/samples/openapi3/client/petstore/python-httpx/docs/HuntingDog.md index 6db6745dd022..114dfc8575d9 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/HuntingDog.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/HuntingDog.md @@ -15,14 +15,14 @@ from petstore_api.models.hunting_dog import HuntingDog # TODO update the JSON string below json = "{}" # create an instance of HuntingDog from a JSON string -hunting_dog_instance = HuntingDog.from_json(json) +hunting_dog_instance = HuntingDog.model_validate_json(json) # print the JSON string representation of the object -print(HuntingDog.to_json()) +print(hunting_dog_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -hunting_dog_dict = hunting_dog_instance.to_dict() +hunting_dog_dict = hunting_dog_instance.model_dump(by_alias=True) # create an instance of HuntingDog from a dict -hunting_dog_from_dict = HuntingDog.from_dict(hunting_dog_dict) +hunting_dog_from_dict = HuntingDog.model_validate(hunting_dog_dict) ``` [[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-httpx/docs/Info.md b/samples/openapi3/client/petstore/python-httpx/docs/Info.md index db88778a9143..160c3633247c 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Info.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Info.md @@ -15,14 +15,14 @@ from petstore_api.models.info import Info # TODO update the JSON string below json = "{}" # create an instance of Info from a JSON string -info_instance = Info.from_json(json) +info_instance = Info.model_validate_json(json) # print the JSON string representation of the object -print(Info.to_json()) +print(info_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -info_dict = info_instance.to_dict() +info_dict = info_instance.model_dump(by_alias=True) # create an instance of Info from a dict -info_from_dict = Info.from_dict(info_dict) +info_from_dict = Info.model_validate(info_dict) ``` [[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-httpx/docs/InnerDictWithProperty.md b/samples/openapi3/client/petstore/python-httpx/docs/InnerDictWithProperty.md index 7b82ebb770b8..79234d754027 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/InnerDictWithProperty.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/InnerDictWithProperty.md @@ -15,14 +15,14 @@ from petstore_api.models.inner_dict_with_property import InnerDictWithProperty # TODO update the JSON string below json = "{}" # create an instance of InnerDictWithProperty from a JSON string -inner_dict_with_property_instance = InnerDictWithProperty.from_json(json) +inner_dict_with_property_instance = InnerDictWithProperty.model_validate_json(json) # print the JSON string representation of the object -print(InnerDictWithProperty.to_json()) +print(inner_dict_with_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -inner_dict_with_property_dict = inner_dict_with_property_instance.to_dict() +inner_dict_with_property_dict = inner_dict_with_property_instance.model_dump(by_alias=True) # create an instance of InnerDictWithProperty from a dict -inner_dict_with_property_from_dict = InnerDictWithProperty.from_dict(inner_dict_with_property_dict) +inner_dict_with_property_from_dict = InnerDictWithProperty.model_validate(inner_dict_with_property_dict) ``` [[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-httpx/docs/InputAllOf.md b/samples/openapi3/client/petstore/python-httpx/docs/InputAllOf.md index 45298f5308fc..32d4100ac9de 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/InputAllOf.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/InputAllOf.md @@ -15,14 +15,14 @@ from petstore_api.models.input_all_of import InputAllOf # TODO update the JSON string below json = "{}" # create an instance of InputAllOf from a JSON string -input_all_of_instance = InputAllOf.from_json(json) +input_all_of_instance = InputAllOf.model_validate_json(json) # print the JSON string representation of the object -print(InputAllOf.to_json()) +print(input_all_of_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -input_all_of_dict = input_all_of_instance.to_dict() +input_all_of_dict = input_all_of_instance.model_dump(by_alias=True) # create an instance of InputAllOf from a dict -input_all_of_from_dict = InputAllOf.from_dict(input_all_of_dict) +input_all_of_from_dict = InputAllOf.model_validate(input_all_of_dict) ``` [[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-httpx/docs/IntOrString.md b/samples/openapi3/client/petstore/python-httpx/docs/IntOrString.md index b4070b9a8c79..ea8e06339493 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/IntOrString.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/IntOrString.md @@ -14,14 +14,14 @@ from petstore_api.models.int_or_string import IntOrString # TODO update the JSON string below json = "{}" # create an instance of IntOrString from a JSON string -int_or_string_instance = IntOrString.from_json(json) +int_or_string_instance = IntOrString.model_validate_json(json) # print the JSON string representation of the object -print(IntOrString.to_json()) +print(int_or_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -int_or_string_dict = int_or_string_instance.to_dict() +int_or_string_dict = int_or_string_instance.model_dump(by_alias=True) # create an instance of IntOrString from a dict -int_or_string_from_dict = IntOrString.from_dict(int_or_string_dict) +int_or_string_from_dict = IntOrString.model_validate(int_or_string_dict) ``` [[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-httpx/docs/ListClass.md b/samples/openapi3/client/petstore/python-httpx/docs/ListClass.md index 01068b7d22c3..8bc905105efe 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ListClass.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ListClass.md @@ -15,14 +15,14 @@ from petstore_api.models.list_class import ListClass # TODO update the JSON string below json = "{}" # create an instance of ListClass from a JSON string -list_class_instance = ListClass.from_json(json) +list_class_instance = ListClass.model_validate_json(json) # print the JSON string representation of the object -print(ListClass.to_json()) +print(list_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -list_class_dict = list_class_instance.to_dict() +list_class_dict = list_class_instance.model_dump(by_alias=True) # create an instance of ListClass from a dict -list_class_from_dict = ListClass.from_dict(list_class_dict) +list_class_from_dict = ListClass.model_validate(list_class_dict) ``` [[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-httpx/docs/MapOfArrayOfModel.md b/samples/openapi3/client/petstore/python-httpx/docs/MapOfArrayOfModel.md index 71a4ef66b682..acea13d9a9f5 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/MapOfArrayOfModel.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/MapOfArrayOfModel.md @@ -15,14 +15,14 @@ from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel # TODO update the JSON string below json = "{}" # create an instance of MapOfArrayOfModel from a JSON string -map_of_array_of_model_instance = MapOfArrayOfModel.from_json(json) +map_of_array_of_model_instance = MapOfArrayOfModel.model_validate_json(json) # print the JSON string representation of the object -print(MapOfArrayOfModel.to_json()) +print(map_of_array_of_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -map_of_array_of_model_dict = map_of_array_of_model_instance.to_dict() +map_of_array_of_model_dict = map_of_array_of_model_instance.model_dump(by_alias=True) # create an instance of MapOfArrayOfModel from a dict -map_of_array_of_model_from_dict = MapOfArrayOfModel.from_dict(map_of_array_of_model_dict) +map_of_array_of_model_from_dict = MapOfArrayOfModel.model_validate(map_of_array_of_model_dict) ``` [[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-httpx/docs/MapTest.md b/samples/openapi3/client/petstore/python-httpx/docs/MapTest.md index d04b82e9378c..fa4501d24286 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/MapTest.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/MapTest.md @@ -18,14 +18,14 @@ from petstore_api.models.map_test import MapTest # TODO update the JSON string below json = "{}" # create an instance of MapTest from a JSON string -map_test_instance = MapTest.from_json(json) +map_test_instance = MapTest.model_validate_json(json) # print the JSON string representation of the object -print(MapTest.to_json()) +print(map_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -map_test_dict = map_test_instance.to_dict() +map_test_dict = map_test_instance.model_dump(by_alias=True) # create an instance of MapTest from a dict -map_test_from_dict = MapTest.from_dict(map_test_dict) +map_test_from_dict = MapTest.model_validate(map_test_dict) ``` [[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-httpx/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-httpx/docs/MixedPropertiesAndAdditionalPropertiesClass.md index 84134317aefc..fb354956720a 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -17,14 +17,14 @@ from petstore_api.models.mixed_properties_and_additional_properties_class import # TODO update the JSON string below json = "{}" # create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string -mixed_properties_and_additional_properties_class_instance = MixedPropertiesAndAdditionalPropertiesClass.from_json(json) +mixed_properties_and_additional_properties_class_instance = MixedPropertiesAndAdditionalPropertiesClass.model_validate_json(json) # print the JSON string representation of the object -print(MixedPropertiesAndAdditionalPropertiesClass.to_json()) +print(mixed_properties_and_additional_properties_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -mixed_properties_and_additional_properties_class_dict = mixed_properties_and_additional_properties_class_instance.to_dict() +mixed_properties_and_additional_properties_class_dict = mixed_properties_and_additional_properties_class_instance.model_dump(by_alias=True) # create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict -mixed_properties_and_additional_properties_class_from_dict = MixedPropertiesAndAdditionalPropertiesClass.from_dict(mixed_properties_and_additional_properties_class_dict) +mixed_properties_and_additional_properties_class_from_dict = MixedPropertiesAndAdditionalPropertiesClass.model_validate(mixed_properties_and_additional_properties_class_dict) ``` [[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-httpx/docs/Model200Response.md b/samples/openapi3/client/petstore/python-httpx/docs/Model200Response.md index 7fdbdefc6cec..6cffad7a6d3a 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Model200Response.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Model200Response.md @@ -17,14 +17,14 @@ from petstore_api.models.model200_response import Model200Response # TODO update the JSON string below json = "{}" # create an instance of Model200Response from a JSON string -model200_response_instance = Model200Response.from_json(json) +model200_response_instance = Model200Response.model_validate_json(json) # print the JSON string representation of the object -print(Model200Response.to_json()) +print(model200_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model200_response_dict = model200_response_instance.to_dict() +model200_response_dict = model200_response_instance.model_dump(by_alias=True) # create an instance of Model200Response from a dict -model200_response_from_dict = Model200Response.from_dict(model200_response_dict) +model200_response_from_dict = Model200Response.model_validate(model200_response_dict) ``` [[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-httpx/docs/ModelApiResponse.md b/samples/openapi3/client/petstore/python-httpx/docs/ModelApiResponse.md index 5ddc0db2a0f3..4fdaa910bce4 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ModelApiResponse.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ModelApiResponse.md @@ -17,14 +17,14 @@ from petstore_api.models.model_api_response import ModelApiResponse # TODO update the JSON string below json = "{}" # create an instance of ModelApiResponse from a JSON string -model_api_response_instance = ModelApiResponse.from_json(json) +model_api_response_instance = ModelApiResponse.model_validate_json(json) # print the JSON string representation of the object -print(ModelApiResponse.to_json()) +print(model_api_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_api_response_dict = model_api_response_instance.to_dict() +model_api_response_dict = model_api_response_instance.model_dump(by_alias=True) # create an instance of ModelApiResponse from a dict -model_api_response_from_dict = ModelApiResponse.from_dict(model_api_response_dict) +model_api_response_from_dict = ModelApiResponse.model_validate(model_api_response_dict) ``` [[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-httpx/docs/ModelField.md b/samples/openapi3/client/petstore/python-httpx/docs/ModelField.md index 9073b5dbdb00..43f064bd85a4 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ModelField.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ModelField.md @@ -15,14 +15,14 @@ from petstore_api.models.model_field import ModelField # TODO update the JSON string below json = "{}" # create an instance of ModelField from a JSON string -model_field_instance = ModelField.from_json(json) +model_field_instance = ModelField.model_validate_json(json) # print the JSON string representation of the object -print(ModelField.to_json()) +print(model_field_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_field_dict = model_field_instance.to_dict() +model_field_dict = model_field_instance.model_dump(by_alias=True) # create an instance of ModelField from a dict -model_field_from_dict = ModelField.from_dict(model_field_dict) +model_field_from_dict = ModelField.model_validate(model_field_dict) ``` [[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-httpx/docs/ModelReturn.md b/samples/openapi3/client/petstore/python-httpx/docs/ModelReturn.md index 7d327053b0c3..236b2bb971ee 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ModelReturn.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ModelReturn.md @@ -16,14 +16,14 @@ from petstore_api.models.model_return import ModelReturn # TODO update the JSON string below json = "{}" # create an instance of ModelReturn from a JSON string -model_return_instance = ModelReturn.from_json(json) +model_return_instance = ModelReturn.model_validate_json(json) # print the JSON string representation of the object -print(ModelReturn.to_json()) +print(model_return_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_return_dict = model_return_instance.to_dict() +model_return_dict = model_return_instance.model_dump(by_alias=True) # create an instance of ModelReturn from a dict -model_return_from_dict = ModelReturn.from_dict(model_return_dict) +model_return_from_dict = ModelReturn.model_validate(model_return_dict) ``` [[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-httpx/docs/MultiArrays.md b/samples/openapi3/client/petstore/python-httpx/docs/MultiArrays.md index fea5139e7e73..9cf5c5bb1faa 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/MultiArrays.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/MultiArrays.md @@ -16,14 +16,14 @@ from petstore_api.models.multi_arrays import MultiArrays # TODO update the JSON string below json = "{}" # create an instance of MultiArrays from a JSON string -multi_arrays_instance = MultiArrays.from_json(json) +multi_arrays_instance = MultiArrays.model_validate_json(json) # print the JSON string representation of the object -print(MultiArrays.to_json()) +print(multi_arrays_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -multi_arrays_dict = multi_arrays_instance.to_dict() +multi_arrays_dict = multi_arrays_instance.model_dump(by_alias=True) # create an instance of MultiArrays from a dict -multi_arrays_from_dict = MultiArrays.from_dict(multi_arrays_dict) +multi_arrays_from_dict = MultiArrays.model_validate(multi_arrays_dict) ``` [[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-httpx/docs/Name.md b/samples/openapi3/client/petstore/python-httpx/docs/Name.md index 5a04ec1ada06..f9d2da4cccd2 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Name.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Name.md @@ -19,14 +19,14 @@ from petstore_api.models.name import Name # TODO update the JSON string below json = "{}" # create an instance of Name from a JSON string -name_instance = Name.from_json(json) +name_instance = Name.model_validate_json(json) # print the JSON string representation of the object -print(Name.to_json()) +print(name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -name_dict = name_instance.to_dict() +name_dict = name_instance.model_dump(by_alias=True) # create an instance of Name from a dict -name_from_dict = Name.from_dict(name_dict) +name_from_dict = Name.model_validate(name_dict) ``` [[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-httpx/docs/NullableClass.md b/samples/openapi3/client/petstore/python-httpx/docs/NullableClass.md index 0387dcc2c67a..cd84aa96eb19 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/NullableClass.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/NullableClass.md @@ -27,14 +27,14 @@ from petstore_api.models.nullable_class import NullableClass # TODO update the JSON string below json = "{}" # create an instance of NullableClass from a JSON string -nullable_class_instance = NullableClass.from_json(json) +nullable_class_instance = NullableClass.model_validate_json(json) # print the JSON string representation of the object -print(NullableClass.to_json()) +print(nullable_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -nullable_class_dict = nullable_class_instance.to_dict() +nullable_class_dict = nullable_class_instance.model_dump(by_alias=True) # create an instance of NullableClass from a dict -nullable_class_from_dict = NullableClass.from_dict(nullable_class_dict) +nullable_class_from_dict = NullableClass.model_validate(nullable_class_dict) ``` [[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-httpx/docs/NullableProperty.md b/samples/openapi3/client/petstore/python-httpx/docs/NullableProperty.md index 30edaf4844b2..c0ef9b80fcb5 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/NullableProperty.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/NullableProperty.md @@ -16,14 +16,14 @@ from petstore_api.models.nullable_property import NullableProperty # TODO update the JSON string below json = "{}" # create an instance of NullableProperty from a JSON string -nullable_property_instance = NullableProperty.from_json(json) +nullable_property_instance = NullableProperty.model_validate_json(json) # print the JSON string representation of the object -print(NullableProperty.to_json()) +print(nullable_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -nullable_property_dict = nullable_property_instance.to_dict() +nullable_property_dict = nullable_property_instance.model_dump(by_alias=True) # create an instance of NullableProperty from a dict -nullable_property_from_dict = NullableProperty.from_dict(nullable_property_dict) +nullable_property_from_dict = NullableProperty.model_validate(nullable_property_dict) ``` [[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-httpx/docs/NumberOnly.md b/samples/openapi3/client/petstore/python-httpx/docs/NumberOnly.md index 415dd25585d4..f1caf70ea2b7 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/NumberOnly.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/NumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.number_only import NumberOnly # TODO update the JSON string below json = "{}" # create an instance of NumberOnly from a JSON string -number_only_instance = NumberOnly.from_json(json) +number_only_instance = NumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(NumberOnly.to_json()) +print(number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -number_only_dict = number_only_instance.to_dict() +number_only_dict = number_only_instance.model_dump(by_alias=True) # create an instance of NumberOnly from a dict -number_only_from_dict = NumberOnly.from_dict(number_only_dict) +number_only_from_dict = NumberOnly.model_validate(number_only_dict) ``` [[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-httpx/docs/ObjectToTestAdditionalProperties.md b/samples/openapi3/client/petstore/python-httpx/docs/ObjectToTestAdditionalProperties.md index f6bc34c98e65..f201a9627dc3 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ObjectToTestAdditionalProperties.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ObjectToTestAdditionalProperties.md @@ -16,14 +16,14 @@ from petstore_api.models.object_to_test_additional_properties import ObjectToTes # TODO update the JSON string below json = "{}" # create an instance of ObjectToTestAdditionalProperties from a JSON string -object_to_test_additional_properties_instance = ObjectToTestAdditionalProperties.from_json(json) +object_to_test_additional_properties_instance = ObjectToTestAdditionalProperties.model_validate_json(json) # print the JSON string representation of the object -print(ObjectToTestAdditionalProperties.to_json()) +print(object_to_test_additional_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -object_to_test_additional_properties_dict = object_to_test_additional_properties_instance.to_dict() +object_to_test_additional_properties_dict = object_to_test_additional_properties_instance.model_dump(by_alias=True) # create an instance of ObjectToTestAdditionalProperties from a dict -object_to_test_additional_properties_from_dict = ObjectToTestAdditionalProperties.from_dict(object_to_test_additional_properties_dict) +object_to_test_additional_properties_from_dict = ObjectToTestAdditionalProperties.model_validate(object_to_test_additional_properties_dict) ``` [[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-httpx/docs/ObjectWithDeprecatedFields.md b/samples/openapi3/client/petstore/python-httpx/docs/ObjectWithDeprecatedFields.md index 6dbd2ace04f1..86cce93ba775 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ObjectWithDeprecatedFields.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ObjectWithDeprecatedFields.md @@ -18,14 +18,14 @@ from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecat # TODO update the JSON string below json = "{}" # create an instance of ObjectWithDeprecatedFields from a JSON string -object_with_deprecated_fields_instance = ObjectWithDeprecatedFields.from_json(json) +object_with_deprecated_fields_instance = ObjectWithDeprecatedFields.model_validate_json(json) # print the JSON string representation of the object -print(ObjectWithDeprecatedFields.to_json()) +print(object_with_deprecated_fields_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -object_with_deprecated_fields_dict = object_with_deprecated_fields_instance.to_dict() +object_with_deprecated_fields_dict = object_with_deprecated_fields_instance.model_dump(by_alias=True) # create an instance of ObjectWithDeprecatedFields from a dict -object_with_deprecated_fields_from_dict = ObjectWithDeprecatedFields.from_dict(object_with_deprecated_fields_dict) +object_with_deprecated_fields_from_dict = ObjectWithDeprecatedFields.model_validate(object_with_deprecated_fields_dict) ``` [[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-httpx/docs/Order.md b/samples/openapi3/client/petstore/python-httpx/docs/Order.md index 00526b8d04b9..f5410bc8d0f3 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Order.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Order.md @@ -20,14 +20,14 @@ from petstore_api.models.order import Order # TODO update the JSON string below json = "{}" # create an instance of Order from a JSON string -order_instance = Order.from_json(json) +order_instance = Order.model_validate_json(json) # print the JSON string representation of the object -print(Order.to_json()) +print(order_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -order_dict = order_instance.to_dict() +order_dict = order_instance.model_dump(by_alias=True) # create an instance of Order from a dict -order_from_dict = Order.from_dict(order_dict) +order_from_dict = Order.model_validate(order_dict) ``` [[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-httpx/docs/OuterComposite.md b/samples/openapi3/client/petstore/python-httpx/docs/OuterComposite.md index c8242c2d2653..9df82e2abc87 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/OuterComposite.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/OuterComposite.md @@ -17,14 +17,14 @@ from petstore_api.models.outer_composite import OuterComposite # TODO update the JSON string below json = "{}" # create an instance of OuterComposite from a JSON string -outer_composite_instance = OuterComposite.from_json(json) +outer_composite_instance = OuterComposite.model_validate_json(json) # print the JSON string representation of the object -print(OuterComposite.to_json()) +print(outer_composite_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -outer_composite_dict = outer_composite_instance.to_dict() +outer_composite_dict = outer_composite_instance.model_dump(by_alias=True) # create an instance of OuterComposite from a dict -outer_composite_from_dict = OuterComposite.from_dict(outer_composite_dict) +outer_composite_from_dict = OuterComposite.model_validate(outer_composite_dict) ``` [[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-httpx/docs/OuterObjectWithEnumProperty.md b/samples/openapi3/client/petstore/python-httpx/docs/OuterObjectWithEnumProperty.md index 6137dbd98da6..d23ccc3757bb 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/OuterObjectWithEnumProperty.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/OuterObjectWithEnumProperty.md @@ -16,14 +16,14 @@ from petstore_api.models.outer_object_with_enum_property import OuterObjectWithE # TODO update the JSON string below json = "{}" # create an instance of OuterObjectWithEnumProperty from a JSON string -outer_object_with_enum_property_instance = OuterObjectWithEnumProperty.from_json(json) +outer_object_with_enum_property_instance = OuterObjectWithEnumProperty.model_validate_json(json) # print the JSON string representation of the object -print(OuterObjectWithEnumProperty.to_json()) +print(outer_object_with_enum_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -outer_object_with_enum_property_dict = outer_object_with_enum_property_instance.to_dict() +outer_object_with_enum_property_dict = outer_object_with_enum_property_instance.model_dump(by_alias=True) # create an instance of OuterObjectWithEnumProperty from a dict -outer_object_with_enum_property_from_dict = OuterObjectWithEnumProperty.from_dict(outer_object_with_enum_property_dict) +outer_object_with_enum_property_from_dict = OuterObjectWithEnumProperty.model_validate(outer_object_with_enum_property_dict) ``` [[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-httpx/docs/Parent.md b/samples/openapi3/client/petstore/python-httpx/docs/Parent.md index 7387f9250aad..21df089ea756 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Parent.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Parent.md @@ -15,14 +15,14 @@ from petstore_api.models.parent import Parent # TODO update the JSON string below json = "{}" # create an instance of Parent from a JSON string -parent_instance = Parent.from_json(json) +parent_instance = Parent.model_validate_json(json) # print the JSON string representation of the object -print(Parent.to_json()) +print(parent_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -parent_dict = parent_instance.to_dict() +parent_dict = parent_instance.model_dump(by_alias=True) # create an instance of Parent from a dict -parent_from_dict = Parent.from_dict(parent_dict) +parent_from_dict = Parent.model_validate(parent_dict) ``` [[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-httpx/docs/ParentWithOptionalDict.md b/samples/openapi3/client/petstore/python-httpx/docs/ParentWithOptionalDict.md index bfc8688ea26f..a6ee19fd1a74 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ParentWithOptionalDict.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ParentWithOptionalDict.md @@ -15,14 +15,14 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict # TODO update the JSON string below json = "{}" # create an instance of ParentWithOptionalDict from a JSON string -parent_with_optional_dict_instance = ParentWithOptionalDict.from_json(json) +parent_with_optional_dict_instance = ParentWithOptionalDict.model_validate_json(json) # print the JSON string representation of the object -print(ParentWithOptionalDict.to_json()) +print(parent_with_optional_dict_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -parent_with_optional_dict_dict = parent_with_optional_dict_instance.to_dict() +parent_with_optional_dict_dict = parent_with_optional_dict_instance.model_dump(by_alias=True) # create an instance of ParentWithOptionalDict from a dict -parent_with_optional_dict_from_dict = ParentWithOptionalDict.from_dict(parent_with_optional_dict_dict) +parent_with_optional_dict_from_dict = ParentWithOptionalDict.model_validate(parent_with_optional_dict_dict) ``` [[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-httpx/docs/Pet.md b/samples/openapi3/client/petstore/python-httpx/docs/Pet.md index 5329cf2fb925..179b71891d9d 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Pet.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Pet.md @@ -20,14 +20,14 @@ from petstore_api.models.pet import Pet # TODO update the JSON string below json = "{}" # create an instance of Pet from a JSON string -pet_instance = Pet.from_json(json) +pet_instance = Pet.model_validate_json(json) # print the JSON string representation of the object -print(Pet.to_json()) +print(pet_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pet_dict = pet_instance.to_dict() +pet_dict = pet_instance.model_dump(by_alias=True) # create an instance of Pet from a dict -pet_from_dict = Pet.from_dict(pet_dict) +pet_from_dict = Pet.model_validate(pet_dict) ``` [[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-httpx/docs/Pig.md b/samples/openapi3/client/petstore/python-httpx/docs/Pig.md index 625930676083..2e275198c547 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Pig.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Pig.md @@ -17,14 +17,14 @@ from petstore_api.models.pig import Pig # TODO update the JSON string below json = "{}" # create an instance of Pig from a JSON string -pig_instance = Pig.from_json(json) +pig_instance = Pig.model_validate_json(json) # print the JSON string representation of the object -print(Pig.to_json()) +print(pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pig_dict = pig_instance.to_dict() +pig_dict = pig_instance.model_dump(by_alias=True) # create an instance of Pig from a dict -pig_from_dict = Pig.from_dict(pig_dict) +pig_from_dict = Pig.model_validate(pig_dict) ``` [[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-httpx/docs/PonySizes.md b/samples/openapi3/client/petstore/python-httpx/docs/PonySizes.md index ced44c872060..6bb28b418b6d 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/PonySizes.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/PonySizes.md @@ -15,14 +15,14 @@ from petstore_api.models.pony_sizes import PonySizes # TODO update the JSON string below json = "{}" # create an instance of PonySizes from a JSON string -pony_sizes_instance = PonySizes.from_json(json) +pony_sizes_instance = PonySizes.model_validate_json(json) # print the JSON string representation of the object -print(PonySizes.to_json()) +print(pony_sizes_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pony_sizes_dict = pony_sizes_instance.to_dict() +pony_sizes_dict = pony_sizes_instance.model_dump(by_alias=True) # create an instance of PonySizes from a dict -pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_dict) +pony_sizes_from_dict = PonySizes.model_validate(pony_sizes_dict) ``` [[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-httpx/docs/PoopCleaning.md b/samples/openapi3/client/petstore/python-httpx/docs/PoopCleaning.md index 8f9c25e08316..3bf20593f929 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/PoopCleaning.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/PoopCleaning.md @@ -17,14 +17,14 @@ from petstore_api.models.poop_cleaning import PoopCleaning # TODO update the JSON string below json = "{}" # create an instance of PoopCleaning from a JSON string -poop_cleaning_instance = PoopCleaning.from_json(json) +poop_cleaning_instance = PoopCleaning.model_validate_json(json) # print the JSON string representation of the object -print(PoopCleaning.to_json()) +print(poop_cleaning_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -poop_cleaning_dict = poop_cleaning_instance.to_dict() +poop_cleaning_dict = poop_cleaning_instance.model_dump(by_alias=True) # create an instance of PoopCleaning from a dict -poop_cleaning_from_dict = PoopCleaning.from_dict(poop_cleaning_dict) +poop_cleaning_from_dict = PoopCleaning.model_validate(poop_cleaning_dict) ``` [[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-httpx/docs/PrimitiveString.md b/samples/openapi3/client/petstore/python-httpx/docs/PrimitiveString.md index 85ceb632e167..a1a9a3dc81b6 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/PrimitiveString.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/PrimitiveString.md @@ -15,14 +15,14 @@ from petstore_api.models.primitive_string import PrimitiveString # TODO update the JSON string below json = "{}" # create an instance of PrimitiveString from a JSON string -primitive_string_instance = PrimitiveString.from_json(json) +primitive_string_instance = PrimitiveString.model_validate_json(json) # print the JSON string representation of the object -print(PrimitiveString.to_json()) +print(primitive_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -primitive_string_dict = primitive_string_instance.to_dict() +primitive_string_dict = primitive_string_instance.model_dump(by_alias=True) # create an instance of PrimitiveString from a dict -primitive_string_from_dict = PrimitiveString.from_dict(primitive_string_dict) +primitive_string_from_dict = PrimitiveString.model_validate(primitive_string_dict) ``` [[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-httpx/docs/PropertyMap.md b/samples/openapi3/client/petstore/python-httpx/docs/PropertyMap.md index a55a0e5c6f01..5fcda1f7803d 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/PropertyMap.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/PropertyMap.md @@ -15,14 +15,14 @@ from petstore_api.models.property_map import PropertyMap # TODO update the JSON string below json = "{}" # create an instance of PropertyMap from a JSON string -property_map_instance = PropertyMap.from_json(json) +property_map_instance = PropertyMap.model_validate_json(json) # print the JSON string representation of the object -print(PropertyMap.to_json()) +print(property_map_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -property_map_dict = property_map_instance.to_dict() +property_map_dict = property_map_instance.model_dump(by_alias=True) # create an instance of PropertyMap from a dict -property_map_from_dict = PropertyMap.from_dict(property_map_dict) +property_map_from_dict = PropertyMap.model_validate(property_map_dict) ``` [[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-httpx/docs/PropertyNameCollision.md b/samples/openapi3/client/petstore/python-httpx/docs/PropertyNameCollision.md index 40c233670dd0..a4a8405fe847 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/PropertyNameCollision.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/PropertyNameCollision.md @@ -17,14 +17,14 @@ from petstore_api.models.property_name_collision import PropertyNameCollision # TODO update the JSON string below json = "{}" # create an instance of PropertyNameCollision from a JSON string -property_name_collision_instance = PropertyNameCollision.from_json(json) +property_name_collision_instance = PropertyNameCollision.model_validate_json(json) # print the JSON string representation of the object -print(PropertyNameCollision.to_json()) +print(property_name_collision_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -property_name_collision_dict = property_name_collision_instance.to_dict() +property_name_collision_dict = property_name_collision_instance.model_dump(by_alias=True) # create an instance of PropertyNameCollision from a dict -property_name_collision_from_dict = PropertyNameCollision.from_dict(property_name_collision_dict) +property_name_collision_from_dict = PropertyNameCollision.model_validate(property_name_collision_dict) ``` [[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-httpx/docs/ReadOnlyFirst.md b/samples/openapi3/client/petstore/python-httpx/docs/ReadOnlyFirst.md index 686ec5da41c9..e55fe102b673 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/ReadOnlyFirst.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/ReadOnlyFirst.md @@ -16,14 +16,14 @@ from petstore_api.models.read_only_first import ReadOnlyFirst # TODO update the JSON string below json = "{}" # create an instance of ReadOnlyFirst from a JSON string -read_only_first_instance = ReadOnlyFirst.from_json(json) +read_only_first_instance = ReadOnlyFirst.model_validate_json(json) # print the JSON string representation of the object -print(ReadOnlyFirst.to_json()) +print(read_only_first_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -read_only_first_dict = read_only_first_instance.to_dict() +read_only_first_dict = read_only_first_instance.model_dump(by_alias=True) # create an instance of ReadOnlyFirst from a dict -read_only_first_from_dict = ReadOnlyFirst.from_dict(read_only_first_dict) +read_only_first_from_dict = ReadOnlyFirst.model_validate(read_only_first_dict) ``` [[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-httpx/docs/SecondCircularAllOfRef.md b/samples/openapi3/client/petstore/python-httpx/docs/SecondCircularAllOfRef.md index 65ebdd4c7e1d..47fb4daf97a4 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/SecondCircularAllOfRef.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/SecondCircularAllOfRef.md @@ -16,14 +16,14 @@ from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRe # TODO update the JSON string below json = "{}" # create an instance of SecondCircularAllOfRef from a JSON string -second_circular_all_of_ref_instance = SecondCircularAllOfRef.from_json(json) +second_circular_all_of_ref_instance = SecondCircularAllOfRef.model_validate_json(json) # print the JSON string representation of the object -print(SecondCircularAllOfRef.to_json()) +print(second_circular_all_of_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -second_circular_all_of_ref_dict = second_circular_all_of_ref_instance.to_dict() +second_circular_all_of_ref_dict = second_circular_all_of_ref_instance.model_dump(by_alias=True) # create an instance of SecondCircularAllOfRef from a dict -second_circular_all_of_ref_from_dict = SecondCircularAllOfRef.from_dict(second_circular_all_of_ref_dict) +second_circular_all_of_ref_from_dict = SecondCircularAllOfRef.model_validate(second_circular_all_of_ref_dict) ``` [[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-httpx/docs/SecondRef.md b/samples/openapi3/client/petstore/python-httpx/docs/SecondRef.md index dfb1a0ac6db5..fa0b9f285e0c 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/SecondRef.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/SecondRef.md @@ -16,14 +16,14 @@ from petstore_api.models.second_ref import SecondRef # TODO update the JSON string below json = "{}" # create an instance of SecondRef from a JSON string -second_ref_instance = SecondRef.from_json(json) +second_ref_instance = SecondRef.model_validate_json(json) # print the JSON string representation of the object -print(SecondRef.to_json()) +print(second_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -second_ref_dict = second_ref_instance.to_dict() +second_ref_dict = second_ref_instance.model_dump(by_alias=True) # create an instance of SecondRef from a dict -second_ref_from_dict = SecondRef.from_dict(second_ref_dict) +second_ref_from_dict = SecondRef.model_validate(second_ref_dict) ``` [[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-httpx/docs/SelfReferenceModel.md b/samples/openapi3/client/petstore/python-httpx/docs/SelfReferenceModel.md index 208cdac04b6f..af3c77d0524b 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/SelfReferenceModel.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/SelfReferenceModel.md @@ -16,14 +16,14 @@ from petstore_api.models.self_reference_model import SelfReferenceModel # TODO update the JSON string below json = "{}" # create an instance of SelfReferenceModel from a JSON string -self_reference_model_instance = SelfReferenceModel.from_json(json) +self_reference_model_instance = SelfReferenceModel.model_validate_json(json) # print the JSON string representation of the object -print(SelfReferenceModel.to_json()) +print(self_reference_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -self_reference_model_dict = self_reference_model_instance.to_dict() +self_reference_model_dict = self_reference_model_instance.model_dump(by_alias=True) # create an instance of SelfReferenceModel from a dict -self_reference_model_from_dict = SelfReferenceModel.from_dict(self_reference_model_dict) +self_reference_model_from_dict = SelfReferenceModel.model_validate(self_reference_model_dict) ``` [[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-httpx/docs/SpecialModelName.md b/samples/openapi3/client/petstore/python-httpx/docs/SpecialModelName.md index 35303f34efd2..589dbeb14b94 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/SpecialModelName.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/SpecialModelName.md @@ -15,14 +15,14 @@ from petstore_api.models.special_model_name import SpecialModelName # TODO update the JSON string below json = "{}" # create an instance of SpecialModelName from a JSON string -special_model_name_instance = SpecialModelName.from_json(json) +special_model_name_instance = SpecialModelName.model_validate_json(json) # print the JSON string representation of the object -print(SpecialModelName.to_json()) +print(special_model_name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -special_model_name_dict = special_model_name_instance.to_dict() +special_model_name_dict = special_model_name_instance.model_dump(by_alias=True) # create an instance of SpecialModelName from a dict -special_model_name_from_dict = SpecialModelName.from_dict(special_model_name_dict) +special_model_name_from_dict = SpecialModelName.model_validate(special_model_name_dict) ``` [[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-httpx/docs/SpecialName.md b/samples/openapi3/client/petstore/python-httpx/docs/SpecialName.md index ccc550b16e33..19da9016451c 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/SpecialName.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/SpecialName.md @@ -17,14 +17,14 @@ from petstore_api.models.special_name import SpecialName # TODO update the JSON string below json = "{}" # create an instance of SpecialName from a JSON string -special_name_instance = SpecialName.from_json(json) +special_name_instance = SpecialName.model_validate_json(json) # print the JSON string representation of the object -print(SpecialName.to_json()) +print(special_name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -special_name_dict = special_name_instance.to_dict() +special_name_dict = special_name_instance.model_dump(by_alias=True) # create an instance of SpecialName from a dict -special_name_from_dict = SpecialName.from_dict(special_name_dict) +special_name_from_dict = SpecialName.model_validate(special_name_dict) ``` [[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-httpx/docs/Tag.md b/samples/openapi3/client/petstore/python-httpx/docs/Tag.md index 4106d9cfe5db..66339d14c875 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Tag.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Tag.md @@ -16,14 +16,14 @@ from petstore_api.models.tag import Tag # TODO update the JSON string below json = "{}" # create an instance of Tag from a JSON string -tag_instance = Tag.from_json(json) +tag_instance = Tag.model_validate_json(json) # print the JSON string representation of the object -print(Tag.to_json()) +print(tag_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tag_dict = tag_instance.to_dict() +tag_dict = tag_instance.model_dump(by_alias=True) # create an instance of Tag from a dict -tag_from_dict = Tag.from_dict(tag_dict) +tag_from_dict = Tag.model_validate(tag_dict) ``` [[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-httpx/docs/Task.md b/samples/openapi3/client/petstore/python-httpx/docs/Task.md index 85fa2776a059..229ed6510a11 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Task.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Task.md @@ -17,14 +17,14 @@ from petstore_api.models.task import Task # TODO update the JSON string below json = "{}" # create an instance of Task from a JSON string -task_instance = Task.from_json(json) +task_instance = Task.model_validate_json(json) # print the JSON string representation of the object -print(Task.to_json()) +print(task_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -task_dict = task_instance.to_dict() +task_dict = task_instance.model_dump(by_alias=True) # create an instance of Task from a dict -task_from_dict = Task.from_dict(task_dict) +task_from_dict = Task.model_validate(task_dict) ``` [[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-httpx/docs/TaskActivity.md b/samples/openapi3/client/petstore/python-httpx/docs/TaskActivity.md index e905a477292d..c025d32ba436 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/TaskActivity.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/TaskActivity.md @@ -17,14 +17,14 @@ from petstore_api.models.task_activity import TaskActivity # TODO update the JSON string below json = "{}" # create an instance of TaskActivity from a JSON string -task_activity_instance = TaskActivity.from_json(json) +task_activity_instance = TaskActivity.model_validate_json(json) # print the JSON string representation of the object -print(TaskActivity.to_json()) +print(task_activity_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -task_activity_dict = task_activity_instance.to_dict() +task_activity_dict = task_activity_instance.model_dump(by_alias=True) # create an instance of TaskActivity from a dict -task_activity_from_dict = TaskActivity.from_dict(task_activity_dict) +task_activity_from_dict = TaskActivity.model_validate(task_activity_dict) ``` [[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-httpx/docs/TestErrorResponsesWithModel400Response.md b/samples/openapi3/client/petstore/python-httpx/docs/TestErrorResponsesWithModel400Response.md index be416bbad0f7..fed06705b55b 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/TestErrorResponsesWithModel400Response.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/TestErrorResponsesWithModel400Response.md @@ -15,14 +15,14 @@ from petstore_api.models.test_error_responses_with_model400_response import Test # TODO update the JSON string below json = "{}" # create an instance of TestErrorResponsesWithModel400Response from a JSON string -test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.from_json(json) +test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.model_validate_json(json) # print the JSON string representation of the object -print(TestErrorResponsesWithModel400Response.to_json()) +print(test_error_responses_with_model400_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.to_dict() +test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.model_dump(by_alias=True) # create an instance of TestErrorResponsesWithModel400Response from a dict -test_error_responses_with_model400_response_from_dict = TestErrorResponsesWithModel400Response.from_dict(test_error_responses_with_model400_response_dict) +test_error_responses_with_model400_response_from_dict = TestErrorResponsesWithModel400Response.model_validate(test_error_responses_with_model400_response_dict) ``` [[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-httpx/docs/TestErrorResponsesWithModel404Response.md b/samples/openapi3/client/petstore/python-httpx/docs/TestErrorResponsesWithModel404Response.md index 1c984f847bf1..8813e0792d22 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/TestErrorResponsesWithModel404Response.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/TestErrorResponsesWithModel404Response.md @@ -15,14 +15,14 @@ from petstore_api.models.test_error_responses_with_model404_response import Test # TODO update the JSON string below json = "{}" # create an instance of TestErrorResponsesWithModel404Response from a JSON string -test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.from_json(json) +test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.model_validate_json(json) # print the JSON string representation of the object -print(TestErrorResponsesWithModel404Response.to_json()) +print(test_error_responses_with_model404_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.to_dict() +test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.model_dump(by_alias=True) # create an instance of TestErrorResponsesWithModel404Response from a dict -test_error_responses_with_model404_response_from_dict = TestErrorResponsesWithModel404Response.from_dict(test_error_responses_with_model404_response_dict) +test_error_responses_with_model404_response_from_dict = TestErrorResponsesWithModel404Response.model_validate(test_error_responses_with_model404_response_dict) ``` [[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-httpx/docs/TestInlineFreeformAdditionalPropertiesRequest.md b/samples/openapi3/client/petstore/python-httpx/docs/TestInlineFreeformAdditionalPropertiesRequest.md index 511132d689be..870cd8850e6b 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/TestInlineFreeformAdditionalPropertiesRequest.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/TestInlineFreeformAdditionalPropertiesRequest.md @@ -15,14 +15,14 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo # TODO update the JSON string below json = "{}" # create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string -test_inline_freeform_additional_properties_request_instance = TestInlineFreeformAdditionalPropertiesRequest.from_json(json) +test_inline_freeform_additional_properties_request_instance = TestInlineFreeformAdditionalPropertiesRequest.model_validate_json(json) # print the JSON string representation of the object -print(TestInlineFreeformAdditionalPropertiesRequest.to_json()) +print(test_inline_freeform_additional_properties_request_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_inline_freeform_additional_properties_request_dict = test_inline_freeform_additional_properties_request_instance.to_dict() +test_inline_freeform_additional_properties_request_dict = test_inline_freeform_additional_properties_request_instance.model_dump(by_alias=True) # create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict -test_inline_freeform_additional_properties_request_from_dict = TestInlineFreeformAdditionalPropertiesRequest.from_dict(test_inline_freeform_additional_properties_request_dict) +test_inline_freeform_additional_properties_request_from_dict = TestInlineFreeformAdditionalPropertiesRequest.model_validate(test_inline_freeform_additional_properties_request_dict) ``` [[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-httpx/docs/TestModelWithEnumDefault.md b/samples/openapi3/client/petstore/python-httpx/docs/TestModelWithEnumDefault.md index 7d46e86deba4..1f63056fe0f1 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/TestModelWithEnumDefault.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/TestModelWithEnumDefault.md @@ -19,14 +19,14 @@ from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDe # TODO update the JSON string below json = "{}" # create an instance of TestModelWithEnumDefault from a JSON string -test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json) +test_model_with_enum_default_instance = TestModelWithEnumDefault.model_validate_json(json) # print the JSON string representation of the object -print(TestModelWithEnumDefault.to_json()) +print(test_model_with_enum_default_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict() +test_model_with_enum_default_dict = test_model_with_enum_default_instance.model_dump(by_alias=True) # create an instance of TestModelWithEnumDefault from a dict -test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict) +test_model_with_enum_default_from_dict = TestModelWithEnumDefault.model_validate(test_model_with_enum_default_dict) ``` [[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-httpx/docs/TestObjectForMultipartRequestsRequestMarker.md b/samples/openapi3/client/petstore/python-httpx/docs/TestObjectForMultipartRequestsRequestMarker.md index ff0ca9ee00ac..bb685d44835a 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/TestObjectForMultipartRequestsRequestMarker.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/TestObjectForMultipartRequestsRequestMarker.md @@ -15,14 +15,14 @@ from petstore_api.models.test_object_for_multipart_requests_request_marker impor # TODO update the JSON string below json = "{}" # create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string -test_object_for_multipart_requests_request_marker_instance = TestObjectForMultipartRequestsRequestMarker.from_json(json) +test_object_for_multipart_requests_request_marker_instance = TestObjectForMultipartRequestsRequestMarker.model_validate_json(json) # print the JSON string representation of the object -print(TestObjectForMultipartRequestsRequestMarker.to_json()) +print(test_object_for_multipart_requests_request_marker_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_object_for_multipart_requests_request_marker_dict = test_object_for_multipart_requests_request_marker_instance.to_dict() +test_object_for_multipart_requests_request_marker_dict = test_object_for_multipart_requests_request_marker_instance.model_dump(by_alias=True) # create an instance of TestObjectForMultipartRequestsRequestMarker from a dict -test_object_for_multipart_requests_request_marker_from_dict = TestObjectForMultipartRequestsRequestMarker.from_dict(test_object_for_multipart_requests_request_marker_dict) +test_object_for_multipart_requests_request_marker_from_dict = TestObjectForMultipartRequestsRequestMarker.model_validate(test_object_for_multipart_requests_request_marker_dict) ``` [[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-httpx/docs/Tiger.md b/samples/openapi3/client/petstore/python-httpx/docs/Tiger.md index f1cf2133f0f7..90c7d8770979 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/Tiger.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/Tiger.md @@ -15,14 +15,14 @@ from petstore_api.models.tiger import Tiger # TODO update the JSON string below json = "{}" # create an instance of Tiger from a JSON string -tiger_instance = Tiger.from_json(json) +tiger_instance = Tiger.model_validate_json(json) # print the JSON string representation of the object -print(Tiger.to_json()) +print(tiger_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tiger_dict = tiger_instance.to_dict() +tiger_dict = tiger_instance.model_dump(by_alias=True) # create an instance of Tiger from a dict -tiger_from_dict = Tiger.from_dict(tiger_dict) +tiger_from_dict = Tiger.model_validate(tiger_dict) ``` [[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-httpx/docs/UnnamedDictWithAdditionalModelListProperties.md b/samples/openapi3/client/petstore/python-httpx/docs/UnnamedDictWithAdditionalModelListProperties.md index 68cd00ab0a7a..0b411bf5df7b 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/UnnamedDictWithAdditionalModelListProperties.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/UnnamedDictWithAdditionalModelListProperties.md @@ -15,14 +15,14 @@ from petstore_api.models.unnamed_dict_with_additional_model_list_properties impo # TODO update the JSON string below json = "{}" # create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string -unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.from_json(json) +unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.model_validate_json(json) # print the JSON string representation of the object -print(UnnamedDictWithAdditionalModelListProperties.to_json()) +print(unnamed_dict_with_additional_model_list_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.to_dict() +unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.model_dump(by_alias=True) # create an instance of UnnamedDictWithAdditionalModelListProperties from a dict -unnamed_dict_with_additional_model_list_properties_from_dict = UnnamedDictWithAdditionalModelListProperties.from_dict(unnamed_dict_with_additional_model_list_properties_dict) +unnamed_dict_with_additional_model_list_properties_from_dict = UnnamedDictWithAdditionalModelListProperties.model_validate(unnamed_dict_with_additional_model_list_properties_dict) ``` [[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-httpx/docs/UnnamedDictWithAdditionalStringListProperties.md b/samples/openapi3/client/petstore/python-httpx/docs/UnnamedDictWithAdditionalStringListProperties.md index 045b0e22ad09..def639720586 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/UnnamedDictWithAdditionalStringListProperties.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/UnnamedDictWithAdditionalStringListProperties.md @@ -15,14 +15,14 @@ from petstore_api.models.unnamed_dict_with_additional_string_list_properties imp # TODO update the JSON string below json = "{}" # create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string -unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.from_json(json) +unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.model_validate_json(json) # print the JSON string representation of the object -print(UnnamedDictWithAdditionalStringListProperties.to_json()) +print(unnamed_dict_with_additional_string_list_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.to_dict() +unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.model_dump(by_alias=True) # create an instance of UnnamedDictWithAdditionalStringListProperties from a dict -unnamed_dict_with_additional_string_list_properties_from_dict = UnnamedDictWithAdditionalStringListProperties.from_dict(unnamed_dict_with_additional_string_list_properties_dict) +unnamed_dict_with_additional_string_list_properties_from_dict = UnnamedDictWithAdditionalStringListProperties.model_validate(unnamed_dict_with_additional_string_list_properties_dict) ``` [[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-httpx/docs/UploadFileWithAdditionalPropertiesRequestObject.md b/samples/openapi3/client/petstore/python-httpx/docs/UploadFileWithAdditionalPropertiesRequestObject.md index 141027780371..35be1642e660 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/UploadFileWithAdditionalPropertiesRequestObject.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/UploadFileWithAdditionalPropertiesRequestObject.md @@ -16,14 +16,14 @@ from petstore_api.models.upload_file_with_additional_properties_request_object i # TODO update the JSON string below json = "{}" # create an instance of UploadFileWithAdditionalPropertiesRequestObject from a JSON string -upload_file_with_additional_properties_request_object_instance = UploadFileWithAdditionalPropertiesRequestObject.from_json(json) +upload_file_with_additional_properties_request_object_instance = UploadFileWithAdditionalPropertiesRequestObject.model_validate_json(json) # print the JSON string representation of the object -print(UploadFileWithAdditionalPropertiesRequestObject.to_json()) +print(upload_file_with_additional_properties_request_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -upload_file_with_additional_properties_request_object_dict = upload_file_with_additional_properties_request_object_instance.to_dict() +upload_file_with_additional_properties_request_object_dict = upload_file_with_additional_properties_request_object_instance.model_dump(by_alias=True) # create an instance of UploadFileWithAdditionalPropertiesRequestObject from a dict -upload_file_with_additional_properties_request_object_from_dict = UploadFileWithAdditionalPropertiesRequestObject.from_dict(upload_file_with_additional_properties_request_object_dict) +upload_file_with_additional_properties_request_object_from_dict = UploadFileWithAdditionalPropertiesRequestObject.model_validate(upload_file_with_additional_properties_request_object_dict) ``` [[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-httpx/docs/User.md b/samples/openapi3/client/petstore/python-httpx/docs/User.md index c45d26d27043..8f4ae3d04712 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/User.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/User.md @@ -22,14 +22,14 @@ from petstore_api.models.user import User # TODO update the JSON string below json = "{}" # create an instance of User from a JSON string -user_instance = User.from_json(json) +user_instance = User.model_validate_json(json) # print the JSON string representation of the object -print(User.to_json()) +print(user_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -user_dict = user_instance.to_dict() +user_dict = user_instance.model_dump(by_alias=True) # create an instance of User from a dict -user_from_dict = User.from_dict(user_dict) +user_from_dict = User.model_validate(user_dict) ``` [[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-httpx/docs/WithNestedOneOf.md b/samples/openapi3/client/petstore/python-httpx/docs/WithNestedOneOf.md index e7bbbc28fc2d..12d648bb920d 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/WithNestedOneOf.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/WithNestedOneOf.md @@ -17,14 +17,14 @@ from petstore_api.models.with_nested_one_of import WithNestedOneOf # TODO update the JSON string below json = "{}" # create an instance of WithNestedOneOf from a JSON string -with_nested_one_of_instance = WithNestedOneOf.from_json(json) +with_nested_one_of_instance = WithNestedOneOf.model_validate_json(json) # print the JSON string representation of the object -print(WithNestedOneOf.to_json()) +print(with_nested_one_of_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -with_nested_one_of_dict = with_nested_one_of_instance.to_dict() +with_nested_one_of_dict = with_nested_one_of_instance.model_dump(by_alias=True) # create an instance of WithNestedOneOf from a dict -with_nested_one_of_from_dict = WithNestedOneOf.from_dict(with_nested_one_of_dict) +with_nested_one_of_from_dict = WithNestedOneOf.model_validate(with_nested_one_of_dict) ``` [[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-httpx/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py index 291b5e55e353..9c810c176590 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesAnyType(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesAnyType(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesAnyType from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesAnyType from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py index 4b2cc457e499..ddbba0f2757e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesClass(BaseModel): """ @@ -37,53 +38,27 @@ class AdditionalPropertiesClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py index 00707c3c4818..75df3dc97cf4 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesObject(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py index d8049b519ed0..a3dea0ab8ee6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesWithDescriptionOnly(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py index 03f554592935..69652540470a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AllOfSuperModel(BaseModel): """ @@ -36,52 +37,27 @@ class AllOfSuperModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AllOfSuperModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AllOfSuperModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py index 44c7da9114a8..e76a1fde6648 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.single_ref_type import SingleRefType from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AllOfWithSingleRef(BaseModel): """ @@ -38,53 +39,27 @@ class AllOfWithSingleRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AllOfWithSingleRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AllOfWithSingleRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "username": obj.get("username"), - "SingleRefType": obj.get("SingleRefType") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py index 56bec73a9ccd..2895047545a5 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -60,52 +61,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Union[Cat, Dog]]: - """Create an instance of Animal from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[Cat, Dog]]: - """Create an instance of Animal from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'Cat': - return import_module("petstore_api.models.cat").Cat.from_dict(obj) - if object_type == 'Dog': - return import_module("petstore_api.models.dog").Dog.from_dict(obj) - - raise ValueError("Animal failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py index f6d277e79498..b86b03be3591 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py @@ -13,8 +13,6 @@ from __future__ import annotations -from inspect import getfullargspec -import json import pprint import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator @@ -22,135 +20,56 @@ from typing_extensions import Annotated from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field +from pydantic import Field, RootModel ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] -class AnyOfColor(BaseModel): + +class AnyOfColor(RootModel[Union[List[int], str]]): """ Any of RGB array, RGBA array, or hex string. """ - # data type: List[int] - anyof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") - # data type: List[int] - anyof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") - # data type: str - anyof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") - if TYPE_CHECKING: - actual_instance: Optional[Union[List[int], str]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { "List[int]", "str" } - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfColor.model_construct() - error_messages = [] - # validate data type: List[int] - try: - instance.anyof_schema_1_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: List[int] - try: - instance.anyof_schema_2_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.anyof_schema_3_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return v + root: Union[List[int], str] = Field( + ... + ) + + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ + + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Self: - return cls.from_json(json.dumps(obj)) + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - # deserialize data into List[int] - try: - # validation - instance.anyof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_1_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into List[int] - try: - # validation - instance.anyof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_2_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.anyof_schema_3_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_3_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) + return self.model_dump_json(by_alias=True, exclude_none=True) - def to_dict(self) -> Optional[Union[Dict[str, Any], List[int], str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) + diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py index c949e136f415..a632d3c382d6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -from inspect import getfullargspec -import json import pprint import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator @@ -23,112 +21,56 @@ from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field +from pydantic import Field, RootModel ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] -class AnyOfPig(BaseModel): + +class AnyOfPig(RootModel[Union[BasquePig, DanishPig]]): """ AnyOfPig """ - # data type: BasquePig - anyof_schema_1_validator: Optional[BasquePig] = None - # data type: DanishPig - anyof_schema_2_validator: Optional[DanishPig] = None - if TYPE_CHECKING: - actual_instance: Optional[Union[BasquePig, DanishPig]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { "BasquePig", "DanishPig" } - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfPig.model_construct() - error_messages = [] - # validate data type: BasquePig - if not isinstance(v, BasquePig): - error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") - else: - return v - - # validate data type: DanishPig - if not isinstance(v, DanishPig): - error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") - else: - return v - - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return v + root: Union[BasquePig, DanishPig] = Field( + ... + ) + + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ + + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Self: - return cls.from_json(json.dumps(obj)) + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - # anyof_schema_1_validator: Optional[BasquePig] = None - try: - instance.actual_instance = BasquePig.from_json(json_str) - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # anyof_schema_2_validator: Optional[DanishPig] = None - try: - instance.actual_instance = DanishPig.from_json(json_str) - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) + return self.model_dump_json(by_alias=True, exclude_none=True) - def to_dict(self) -> Optional[Union[Dict[str, Any], BasquePig, DanishPig]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) + diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py index 4f8eeda66c30..dfc9ac6c4ca5 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfArrayOfModel(BaseModel): """ @@ -37,64 +38,27 @@ class ArrayOfArrayOfModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) - _items = [] - if self.another_property: - for _item_another_property in self.another_property: - if _item_another_property: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] - ) - _dict['another_property'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "another_property": [ - [Tag.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["another_property"] - ] if obj.get("another_property") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py index 02b0f6d657f4..3ad948c9440d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfArrayOfNumberOnly(BaseModel): """ @@ -36,52 +37,27 @@ class ArrayOfArrayOfNumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfNumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfNumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "ArrayArrayNumber": obj.get("ArrayArrayNumber") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py index b22632b0ce4d..1d4adc5a950a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfNumberOnly(BaseModel): """ @@ -36,52 +37,27 @@ class ArrayOfNumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfNumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfNumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "ArrayNumber": obj.get("ArrayNumber") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py index e8f8acf67cc0..5adbf20df093 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py @@ -22,7 +22,8 @@ from typing_extensions import Annotated from petstore_api.models.read_only_first import ReadOnlyFirst from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayTest(BaseModel): """ @@ -41,67 +42,27 @@ class ArrayTest(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) - _items = [] - if self.array_array_of_model: - for _item_array_array_of_model in self.array_array_of_model: - if _item_array_array_of_model: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] - ) - _dict['array_array_of_model'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "array_of_string": obj.get("array_of_string"), - "array_of_nullable_float": obj.get("array_of_nullable_float"), - "array_array_of_integer": obj.get("array_array_of_integer"), - "array_array_of_model": [ - [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["array_array_of_model"] - ] if obj.get("array_array_of_model") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py index f13c270b56b5..9503c06d45bc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -59,52 +60,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Union[PrimitiveString, Info]]: - """Create an instance of BaseDiscriminator from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[PrimitiveString, Info]]: - """Create an instance of BaseDiscriminator from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'PrimitiveString': - return import_module("petstore_api.models.primitive_string").PrimitiveString.from_dict(obj) - if object_type == 'Info': - return import_module("petstore_api.models.info").Info.from_dict(obj) - - raise ValueError("BaseDiscriminator failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py index a1f32a6edcfc..34c4a06b6cbd 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class BasquePig(BaseModel): """ @@ -37,53 +38,27 @@ class BasquePig(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of BasquePig from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of BasquePig from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py index 088e6ad3b873..732c1aa3042a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Bathing(BaseModel): """ Bathing """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning_deep'] = Field( + ..., + description="task_name of the Bathing", + alias="task_name" + ) + function_name: Literal['care_nourish'] = Field( + ..., + description="function_name of the Bathing", + alias="function_name" + ) content: StrictStr __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -52,54 +61,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Bathing from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Bathing from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py index b3c20af54440..28449afd3e5a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Capitalization(BaseModel): """ @@ -41,57 +42,27 @@ class Capitalization(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Capitalization from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Capitalization from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "smallCamel": obj.get("smallCamel"), - "CapitalCamel": obj.get("CapitalCamel"), - "small_Snake": obj.get("small_Snake"), - "Capital_Snake": obj.get("Capital_Snake"), - "SCA_ETH_Flow_Points": obj.get("SCA_ETH_Flow_Points"), - "ATT_NAME": obj.get("ATT_NAME") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py index 0c2c9788dca3..4a93e75fad72 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Cat(Animal): """ @@ -37,54 +38,27 @@ class Cat(Animal): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Cat from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Cat from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") if obj.get("color") is not None else 'red', - "declawed": obj.get("declawed") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py index dcc6247b5ac7..aa4daee49387 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Category(BaseModel): """ @@ -37,53 +38,27 @@ class Category(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Category from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Category from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") if obj.get("name") is not None else 'default-name' - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py index f98247ae0fb5..208e5958632d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CircularAllOfRef(BaseModel): """ @@ -37,61 +38,28 @@ class CircularAllOfRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CircularAllOfRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in second_circular_all_of_ref (list) - _items = [] - if self.second_circular_all_of_ref: - for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: - if _item_second_circular_all_of_ref: - _items.append(_item_second_circular_all_of_ref.to_dict()) - _dict['secondCircularAllOfRef'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CircularAllOfRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name"), - "secondCircularAllOfRef": [SecondCircularAllOfRef.from_dict(_item) for _item in obj["secondCircularAllOfRef"]] if obj.get("secondCircularAllOfRef") is not None else None - }) - return _obj from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py index 3b2854caaac2..f3a5c5c72ceb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CircularReferenceModel(BaseModel): """ @@ -37,57 +38,28 @@ class CircularReferenceModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CircularReferenceModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested - if self.nested: - _dict['nested'] = self.nested.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CircularReferenceModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested": FirstRef.from_dict(obj["nested"]) if obj.get("nested") is not None else None - }) - return _obj from petstore_api.models.first_ref import FirstRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py index 6def0e52d146..39b738f37734 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ClassModel(BaseModel): """ @@ -36,52 +37,27 @@ class ClassModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ClassModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ClassModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_class": obj.get("_class") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py index 1c12c9a145c8..f0cce9f3cb96 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Client(BaseModel): """ @@ -36,52 +37,27 @@ class Client(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Client from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Client from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "client": obj.get("client") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py index bb740fb597d4..5197fe58ecc6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py @@ -18,150 +18,55 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] -class Color(BaseModel): +class Color(RootModel[Union[List[int], str]]): """ RGB array, RGBA array, or hex string. """ - # data type: List[int] - oneof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") - # data type: List[int] - oneof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") - # data type: str - oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") - actual_instance: Optional[Union[List[int], str]] = None - one_of_schemas: Set[str] = { "List[int]", "str" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[List[int], str, None] = Field( + None ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - if v is None: - return v - - instance = Color.model_construct() - error_messages = [] - match = 0 - # validate data type: List[int] - try: - instance.oneof_schema_1_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: List[int] - try: - instance.oneof_schema_2_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.oneof_schema_3_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: Optional[str]) -> Self: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - if json_str is None: - return instance - - error_messages = [] - match = 0 - - # deserialize data into List[int] - try: - # validation - instance.oneof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_1_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into List[int] - try: - # validation - instance.oneof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_2_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.oneof_schema_3_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_3_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], List[int], str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py index 2ed3aa42bf99..9f3f914c2b72 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py @@ -22,7 +22,8 @@ from typing import Any, ClassVar, Dict, List, Union from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -60,53 +61,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[HuntingDog]]: - """Create an instance of Creature from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of info - if self.info: - _dict['info'] = self.info.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[HuntingDog]]: - """Create an instance of Creature from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'HuntingDog': - return import_module("petstore_api.models.hunting_dog").HuntingDog.from_dict(obj) - - raise ValueError("Creature failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py index e7927446c238..9b70835e860e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CreatureInfo(BaseModel): """ @@ -36,52 +37,27 @@ class CreatureInfo(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CreatureInfo from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CreatureInfo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py index 061e16a486a5..b9521312c8e8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DanishPig(BaseModel): """ @@ -37,53 +38,27 @@ class DanishPig(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DanishPig from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DanishPig from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "size": obj.get("size") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py index bb4747a1e18c..3c7fbe91d2f2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DeprecatedObject(BaseModel): """ @@ -36,52 +37,27 @@ class DeprecatedObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DeprecatedObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DeprecatedObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py index 2e8d4a6d7633..9f5f1144a513 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List from petstore_api.models.discriminator_all_of_super import DiscriminatorAllOfSuper from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DiscriminatorAllOfSub(DiscriminatorAllOfSuper): """ @@ -36,52 +37,27 @@ class DiscriminatorAllOfSub(DiscriminatorAllOfSuper): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DiscriminatorAllOfSub from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DiscriminatorAllOfSub from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "elementType": obj.get("elementType") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py index ee910f90ea69..f2e5c978592b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -58,50 +59,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Union[DiscriminatorAllOfSub]]: - """Create an instance of DiscriminatorAllOfSuper from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[DiscriminatorAllOfSub]]: - """Create an instance of DiscriminatorAllOfSuper from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'DiscriminatorAllOfSub': - return import_module("petstore_api.models.discriminator_all_of_sub").DiscriminatorAllOfSub.from_dict(obj) - - raise ValueError("DiscriminatorAllOfSuper failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py index a0f4ed786b4e..ee2df1d87aac 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Dog(Animal): """ @@ -37,54 +38,27 @@ class Dog(Animal): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Dog from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Dog from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") if obj.get("color") is not None else 'red', - "breed": obj.get("breed") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py index 3050cbf66dc4..f2ddcef5972a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DummyModel(BaseModel): """ @@ -37,57 +38,28 @@ class DummyModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DummyModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of self_ref - if self.self_ref: - _dict['self_ref'] = self.self_ref.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DummyModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "self_ref": SelfReferenceModel.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None - }) - return _obj from petstore_api.models.self_reference_model import SelfReferenceModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py index 68ceb962b03e..5a46c33280ca 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py @@ -20,14 +20,21 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumArrays(BaseModel): """ EnumArrays """ # noqa: E501 - just_symbol: Optional[StrictStr] = None - array_enum: Optional[List[StrictStr]] = None + just_symbol: Optional[Literal['>=', '$']] = Field( + None, + description="just_symbol of the EnumArrays" + ) + array_enum: Optional[List[Literal['fish', 'crab']]] = Field( + None, + description="array_enum of the EnumArrays" + ) __properties: ClassVar[List[str]] = ["just_symbol", "array_enum"] @field_validator('just_symbol') @@ -58,53 +65,27 @@ def array_enum_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumArrays from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumArrays from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "just_symbol": obj.get("just_symbol"), - "array_enum": obj.get("array_enum") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py index 9d97e3fd16d4..b51873522c71 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.data_output_format import DataOutputFormat from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumRefWithDefaultValue(BaseModel): """ @@ -37,52 +38,27 @@ class EnumRefWithDefaultValue(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumRefWithDefaultValue from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumRefWithDefaultValue from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "report_format": obj.get("report_format") if obj.get("report_format") is not None else DataOutputFormat.JSON - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py index b7e6ec36230f..cc8235f31d2f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py @@ -26,19 +26,43 @@ from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumTest(BaseModel): """ EnumTest """ # noqa: E501 - enum_string: Optional[StrictStr] = None - enum_string_required: StrictStr - enum_integer_default: Optional[StrictInt] = 5 - enum_integer: Optional[StrictInt] = None - enum_number: Optional[float] = None - enum_string_single_member: Optional[StrictStr] = None - enum_integer_single_member: Optional[StrictInt] = None + enum_string: Optional[Literal['UPPER', 'lower', '']] = Field( + None, + description="enum_string of the EnumTest" + ) + enum_string_required: Literal['UPPER', 'lower', ''] = Field( + ..., + description="enum_string_required of the EnumTest" + ) + enum_integer_default: Optional[Literal[1, 5, 14]] = Field( + None, + description="enum_integer_default of the EnumTest" + ) + enum_integer: Optional[Literal[1, -1]] = Field( + None, + description="enum_integer of the EnumTest" + ) + enum_number: Optional[Literal[1.1, -1.2]] = Field( + None, + description="enum_number of the EnumTest" + ) + enum_string_single_member: Literal['abc'] = Field( + None, + description="enum_string_single_member of the EnumTest", + alias="enum_string_single_member" + ) + enum_integer_single_member: Literal['100'] = Field( + None, + description="enum_integer_single_member of the EnumTest", + alias="enum_integer_single_member" + ) outer_enum: Optional[OuterEnum] = Field(default=None, alias="outerEnum") outer_enum_integer: Optional[OuterEnumInteger] = Field(default=None, alias="outerEnumInteger") outer_enum_default_value: Optional[OuterEnumDefaultValue] = Field(default=OuterEnumDefaultValue.PLACED, alias="outerEnumDefaultValue") @@ -121,69 +145,27 @@ def enum_integer_single_member_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if outer_enum (nullable) is None - # and model_fields_set contains the field - if self.outer_enum is None and "outer_enum" in self.model_fields_set: - _dict['outerEnum'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "enum_string": obj.get("enum_string"), - "enum_string_required": obj.get("enum_string_required"), - "enum_integer_default": obj.get("enum_integer_default") if obj.get("enum_integer_default") is not None else 5, - "enum_integer": obj.get("enum_integer"), - "enum_number": obj.get("enum_number"), - "enum_string_single_member": obj.get("enum_string_single_member"), - "enum_integer_single_member": obj.get("enum_integer_single_member"), - "outerEnum": obj.get("outerEnum"), - "outerEnumInteger": obj.get("outerEnumInteger"), - "outerEnumDefaultValue": obj.get("outerEnumDefaultValue") if obj.get("outerEnumDefaultValue") is not None else OuterEnumDefaultValue.PLACED, - "outerEnumIntegerDefaultValue": obj.get("outerEnumIntegerDefaultValue") if obj.get("outerEnumIntegerDefaultValue") is not None else OuterEnumIntegerDefaultValue.NUMBER_0, - "enumNumberVendorExt": obj.get("enumNumberVendorExt"), - "enumStringVendorExt": obj.get("enumStringVendorExt") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py index 1183b314fdd0..ed0623f5e1ca 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Feeding(BaseModel): """ Feeding """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning'] = Field( + ..., + description="task_name of the Feeding", + alias="task_name" + ) + function_name: Literal['care_nourish'] = Field( + ..., + description="function_name of the Feeding", + alias="function_name" + ) content: StrictStr __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -52,54 +61,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Feeding from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Feeding from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py index 0ecacf44bb8e..39a9df75cceb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class File(BaseModel): """ @@ -36,52 +37,27 @@ class File(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of File from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of File from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "sourceURI": obj.get("sourceURI") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py index c533c0777b24..8a35d95893ab 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.file import File from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FileSchemaTestClass(BaseModel): """ @@ -38,63 +39,27 @@ class FileSchemaTestClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FileSchemaTestClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of file - if self.file: - _dict['file'] = self.file.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in files (list) - _items = [] - if self.files: - for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) - _dict['files'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FileSchemaTestClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "file": File.from_dict(obj["file"]) if obj.get("file") is not None else None, - "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py index 6aa0f722d874..13bee22b64e4 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FirstRef(BaseModel): """ @@ -37,57 +38,28 @@ class FirstRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FirstRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of self_ref - if self.self_ref: - _dict['self_ref'] = self.self_ref.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FirstRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "self_ref": SecondRef.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None - }) - return _obj from petstore_api.models.second_ref import SecondRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py index 67b29f1ab87c..a1b2ca180494 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Foo(BaseModel): """ @@ -36,52 +37,27 @@ class Foo(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Foo from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Foo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar") if obj.get("bar") is not None else 'bar' - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py index ae191aad80a8..3fe6d71bf00e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.foo import Foo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FooGetDefaultResponse(BaseModel): """ @@ -37,55 +38,27 @@ class FooGetDefaultResponse(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FooGetDefaultResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of string - if self.string: - _dict['string'] = self.string.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FooGetDefaultResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "string": Foo.from_dict(obj["string"]) if obj.get("string") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py index 8d70a96f3a7c..368933863a9a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py @@ -24,7 +24,8 @@ from typing_extensions import Annotated from uuid import UUID from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FormatTest(BaseModel): """ @@ -96,68 +97,27 @@ def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FormatTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FormatTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "integer": obj.get("integer"), - "int32": obj.get("int32"), - "int64": obj.get("int64"), - "number": obj.get("number"), - "float": obj.get("float"), - "double": obj.get("double"), - "decimal": obj.get("decimal"), - "string": obj.get("string"), - "string_with_double_quote_pattern": obj.get("string_with_double_quote_pattern"), - "byte": obj.get("byte"), - "binary": obj.get("binary"), - "date": obj.get("date"), - "dateTime": obj.get("dateTime"), - "uuid": obj.get("uuid"), - "password": obj.get("password"), - "pattern_with_digits": obj.get("pattern_with_digits"), - "pattern_with_digits_and_delimiter": obj.get("pattern_with_digits_and_delimiter") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py index 2137bc880484..07a8241f5eb4 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HasOnlyReadOnly(BaseModel): """ @@ -37,57 +38,27 @@ class HasOnlyReadOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HasOnlyReadOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * OpenAPI `readOnly` fields are excluded. - """ - excluded_fields: Set[str] = set([ - "bar", - "foo", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HasOnlyReadOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar"), - "foo": obj.get("foo") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py index 4dbdd852097f..eb842ad8defc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HealthCheckResult(BaseModel): """ @@ -36,57 +37,27 @@ class HealthCheckResult(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HealthCheckResult from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if nullable_message (nullable) is None - # and model_fields_set contains the field - if self.nullable_message is None and "nullable_message" in self.model_fields_set: - _dict['NullableMessage'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HealthCheckResult from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "NullableMessage": obj.get("NullableMessage") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py index cd678616f62f..9460c3da660e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py @@ -22,7 +22,8 @@ from petstore_api.models.creature import Creature from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HuntingDog(Creature): """ @@ -38,57 +39,27 @@ class HuntingDog(Creature): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HuntingDog from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of info - if self.info: - _dict['info'] = self.info.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HuntingDog from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "info": CreatureInfo.from_dict(obj["info"]) if obj.get("info") is not None else None, - "type": obj.get("type"), - "isTrained": obj.get("isTrained") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py index 5a15b5f9f52f..9a4cf4070256 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.base_discriminator import BaseDiscriminator from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Info(BaseDiscriminator): """ @@ -37,56 +38,27 @@ class Info(BaseDiscriminator): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Info from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of val - if self.val: - _dict['val'] = self.val.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Info from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_typeName": obj.get("_typeName"), - "val": BaseDiscriminator.from_dict(obj["val"]) if obj.get("val") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py index 27816b995f53..3165bf3a065d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class InnerDictWithProperty(BaseModel): """ @@ -36,52 +37,27 @@ class InnerDictWithProperty(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of InnerDictWithProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of InnerDictWithProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "aProperty": obj.get("aProperty") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py index 63870cca83ed..cc09b8ea0c29 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class InputAllOf(BaseModel): """ @@ -37,64 +38,27 @@ class InputAllOf(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of InputAllOf from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) - _field_dict = {} - if self.some_data: - for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - _dict['some_data'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of InputAllOf from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "some_data": dict( - (_k, Tag.from_dict(_v)) - for _k, _v in obj["some_data"].items() - ) - if obj.get("some_data") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py index f2a5a0a2d4a3..c66bf1ab9772 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py @@ -18,127 +18,55 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] -class IntOrString(BaseModel): +class IntOrString(RootModel[Union[int, str]]): """ IntOrString """ - # data type: int - oneof_schema_1_validator: Optional[Annotated[int, Field(strict=True, ge=10)]] = None - # data type: str - oneof_schema_2_validator: Optional[StrictStr] = None - actual_instance: Optional[Union[int, str]] = None - one_of_schemas: Set[str] = { "int", "str" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[int, str] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = IntOrString.model_construct() - error_messages = [] - match = 0 - # validate data type: int - try: - instance.oneof_schema_1_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.oneof_schema_2_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into int - try: - # validation - instance.oneof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_1_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.oneof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_2_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py index ab12a7fac521..0a5f1ac36d43 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ListClass(BaseModel): """ @@ -36,52 +37,27 @@ class ListClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ListClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ListClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "123-list": obj.get("123-list") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py index a9bd000ad9ba..bd926af80b11 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MapOfArrayOfModel(BaseModel): """ @@ -37,68 +38,27 @@ class MapOfArrayOfModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MapOfArrayOfModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array) - _field_dict_of_array = {} - if self.shop_id_to_org_online_lip_map: - for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ - _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] - ] - _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MapOfArrayOfModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "shopIdToOrgOnlineLipMap": dict( - (_k, - [Tag.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("shopIdToOrgOnlineLipMap", {}).items() - ) - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py index 2a056ab5532a..591b729eb6a1 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py @@ -20,14 +20,18 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MapTest(BaseModel): """ MapTest """ # noqa: E501 map_map_of_string: Optional[Dict[str, Dict[str, StrictStr]]] = None - map_of_enum_string: Optional[Dict[str, StrictStr]] = None + map_of_enum_string: Optional[Literal['UPPER', 'lower']] = Field( + None, + description="map_of_enum_string of the MapTest" + ) direct_map: Optional[Dict[str, StrictBool]] = None indirect_map: Optional[Dict[str, StrictBool]] = None __properties: ClassVar[List[str]] = ["map_map_of_string", "map_of_enum_string", "direct_map", "indirect_map"] @@ -50,55 +54,27 @@ def map_of_enum_string_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MapTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MapTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "map_map_of_string": obj.get("map_map_of_string"), - "map_of_enum_string": obj.get("map_of_enum_string"), - "direct_map": obj.get("direct_map"), - "indirect_map": obj.get("indirect_map") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py index 46998dfb5c68..d4f415fe0afa 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -23,7 +23,8 @@ from uuid import UUID from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): """ @@ -41,66 +42,27 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in map (dict) - _field_dict = {} - if self.map: - for _key_map in self.map: - if self.map[_key_map]: - _field_dict[_key_map] = self.map[_key_map].to_dict() - _dict['map'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "uuid": obj.get("uuid"), - "dateTime": obj.get("dateTime"), - "map": dict( - (_k, Animal.from_dict(_v)) - for _k, _v in obj["map"].items() - ) - if obj.get("map") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py index d6012c57fbd7..f4186542b9e7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Model200Response(BaseModel): """ @@ -37,53 +38,27 @@ class Model200Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Model200Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Model200Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "class": obj.get("class") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py index 005c77823bef..4556075a0995 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelApiResponse(BaseModel): """ @@ -38,54 +39,27 @@ class ModelApiResponse(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelApiResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelApiResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "code": obj.get("code"), - "type": obj.get("type"), - "message": obj.get("message") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py index 9e36a6ac7e48..eed3b9237d74 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelField(BaseModel): """ @@ -36,52 +37,27 @@ class ModelField(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelField from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelField from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "field": obj.get("field") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py index a8c0f53f6c19..a6760c8a3650 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelReturn(BaseModel): """ @@ -36,52 +37,27 @@ class ModelReturn(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelReturn from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelReturn from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "return": obj.get("return") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py index 177a8359468f..b50d7f9ad4b3 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py @@ -22,7 +22,8 @@ from petstore_api.models.file import File from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MultiArrays(BaseModel): """ @@ -39,67 +40,27 @@ class MultiArrays(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MultiArrays from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - # override the default output from pydantic by calling `to_dict()` of each item in files (list) - _items = [] - if self.files: - for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) - _dict['files'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MultiArrays from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py index f33b2ecb18be..67265006c173 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Name(BaseModel): """ @@ -39,59 +40,27 @@ class Name(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Name from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * OpenAPI `readOnly` fields are excluded. - """ - excluded_fields: Set[str] = set([ - "snake_case", - "var_123_number", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Name from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "snake_case": obj.get("snake_case"), - "property": obj.get("property"), - "123Number": obj.get("123Number") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py index 9d1414954830..19824ad3bfcc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NullableClass(BaseModel): """ @@ -50,131 +51,27 @@ class NullableClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NullableClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if required_integer_prop (nullable) is None - # and model_fields_set contains the field - if self.required_integer_prop is None and "required_integer_prop" in self.model_fields_set: - _dict['required_integer_prop'] = None - - # set to None if integer_prop (nullable) is None - # and model_fields_set contains the field - if self.integer_prop is None and "integer_prop" in self.model_fields_set: - _dict['integer_prop'] = None - - # set to None if number_prop (nullable) is None - # and model_fields_set contains the field - if self.number_prop is None and "number_prop" in self.model_fields_set: - _dict['number_prop'] = None - - # set to None if boolean_prop (nullable) is None - # and model_fields_set contains the field - if self.boolean_prop is None and "boolean_prop" in self.model_fields_set: - _dict['boolean_prop'] = None - - # set to None if string_prop (nullable) is None - # and model_fields_set contains the field - if self.string_prop is None and "string_prop" in self.model_fields_set: - _dict['string_prop'] = None - - # set to None if date_prop (nullable) is None - # and model_fields_set contains the field - if self.date_prop is None and "date_prop" in self.model_fields_set: - _dict['date_prop'] = None - - # set to None if datetime_prop (nullable) is None - # and model_fields_set contains the field - if self.datetime_prop is None and "datetime_prop" in self.model_fields_set: - _dict['datetime_prop'] = None - - # set to None if array_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.array_nullable_prop is None and "array_nullable_prop" in self.model_fields_set: - _dict['array_nullable_prop'] = None - - # set to None if array_and_items_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.array_and_items_nullable_prop is None and "array_and_items_nullable_prop" in self.model_fields_set: - _dict['array_and_items_nullable_prop'] = None - - # set to None if object_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.object_nullable_prop is None and "object_nullable_prop" in self.model_fields_set: - _dict['object_nullable_prop'] = None - - # set to None if object_and_items_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.object_and_items_nullable_prop is None and "object_and_items_nullable_prop" in self.model_fields_set: - _dict['object_and_items_nullable_prop'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NullableClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "required_integer_prop": obj.get("required_integer_prop"), - "integer_prop": obj.get("integer_prop"), - "number_prop": obj.get("number_prop"), - "boolean_prop": obj.get("boolean_prop"), - "string_prop": obj.get("string_prop"), - "date_prop": obj.get("date_prop"), - "datetime_prop": obj.get("datetime_prop"), - "array_nullable_prop": obj.get("array_nullable_prop"), - "array_and_items_nullable_prop": obj.get("array_and_items_nullable_prop"), - "array_items_nullable": obj.get("array_items_nullable"), - "object_nullable_prop": obj.get("object_nullable_prop"), - "object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"), - "object_items_nullable": obj.get("object_items_nullable") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py index 2324745d7dd1..57dd94a70c10 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NullableProperty(BaseModel): """ @@ -48,58 +49,27 @@ def name_validate_regular_expression(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NullableProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if name (nullable) is None - # and model_fields_set contains the field - if self.name is None and "name" in self.model_fields_set: - _dict['name'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NullableProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py index 18c3ec953080..5745c6ae695f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NumberOnly(BaseModel): """ @@ -36,52 +37,27 @@ class NumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "JustNumber": obj.get("JustNumber") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py index 22b8bd401a1c..0823a0a2474b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictBool from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ObjectToTestAdditionalProperties(BaseModel): """ @@ -36,52 +37,27 @@ class ObjectToTestAdditionalProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ObjectToTestAdditionalProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ObjectToTestAdditionalProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "property": obj.get("property") if obj.get("property") is not None else False - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py index 4d76d9f5fc72..e9ef0f373e91 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.deprecated_object import DeprecatedObject from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ObjectWithDeprecatedFields(BaseModel): """ @@ -40,58 +41,27 @@ class ObjectWithDeprecatedFields(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ObjectWithDeprecatedFields from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of deprecated_ref - if self.deprecated_ref: - _dict['deprecatedRef'] = self.deprecated_ref.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ObjectWithDeprecatedFields from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "uuid": obj.get("uuid"), - "id": obj.get("id"), - "deprecatedRef": DeprecatedObject.from_dict(obj["deprecatedRef"]) if obj.get("deprecatedRef") is not None else None, - "bars": obj.get("bars") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py index f742027e088a..0b8441532ba5 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Order(BaseModel): """ @@ -31,7 +32,10 @@ class Order(BaseModel): pet_id: Optional[StrictInt] = Field(default=None, alias="petId") quantity: Optional[StrictInt] = None ship_date: Optional[datetime] = Field(default=None, alias="shipDate") - status: Optional[StrictStr] = Field(default=None, description="Order Status") + status: Optional[Literal['placed', 'approved', 'delivered']] = Field( + None, + description="Order Status" + ) complete: Optional[StrictBool] = False __properties: ClassVar[List[str]] = ["id", "petId", "quantity", "shipDate", "status", "complete"] @@ -52,57 +56,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Order from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Order from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "petId": obj.get("petId"), - "quantity": obj.get("quantity"), - "shipDate": obj.get("shipDate"), - "status": obj.get("status"), - "complete": obj.get("complete") if obj.get("complete") is not None else False - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py index 6a82d49970cb..fe85ee49ca06 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class OuterComposite(BaseModel): """ @@ -38,54 +39,27 @@ class OuterComposite(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OuterComposite from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OuterComposite from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "my_number": obj.get("my_number"), - "my_string": obj.get("my_string"), - "my_boolean": obj.get("my_boolean") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py index 4f453c2a8d0c..4daabab35807 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py @@ -22,7 +22,8 @@ from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class OuterObjectWithEnumProperty(BaseModel): """ @@ -39,58 +40,27 @@ class OuterObjectWithEnumProperty(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OuterObjectWithEnumProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # set to None if str_value (nullable) is None - # and model_fields_set contains the field - if self.str_value is None and "str_value" in self.model_fields_set: - _dict['str_value'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OuterObjectWithEnumProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "str_value": obj.get("str_value"), - "value": obj.get("value") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py index 5986da45ab04..347ed325ae05 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Parent(BaseModel): """ @@ -37,64 +38,27 @@ class Parent(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Parent from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) - _field_dict = {} - if self.optional_dict: - for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - _dict['optionalDict'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Parent from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "optionalDict": dict( - (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj["optionalDict"].items() - ) - if obj.get("optionalDict") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py index 84445b64043a..6cab92407738 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ParentWithOptionalDict(BaseModel): """ @@ -37,64 +38,27 @@ class ParentWithOptionalDict(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ParentWithOptionalDict from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) - _field_dict = {} - if self.optional_dict: - for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - _dict['optionalDict'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ParentWithOptionalDict from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "optionalDict": dict( - (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj["optionalDict"].items() - ) - if obj.get("optionalDict") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py index be47c3b1a894..dbef9d16f443 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py @@ -23,7 +23,8 @@ from petstore_api.models.category import Category from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Pet(BaseModel): """ @@ -34,7 +35,10 @@ class Pet(BaseModel): name: StrictStr photo_urls: Annotated[List[StrictStr], Field(min_length=0)] = Field(alias="photoUrls") tags: Optional[List[Tag]] = None - status: Optional[StrictStr] = Field(default=None, description="pet status in the store") + status: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) __properties: ClassVar[List[str]] = ["id", "category", "name", "photoUrls", "tags", "status"] @field_validator('status') @@ -54,67 +58,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Pet from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of category - if self.category: - _dict['category'] = self.category.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Pet from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, - "name": obj.get("name"), - "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "status": obj.get("status") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py index b3a759e89b7b..6646e6d477cd 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py @@ -19,122 +19,55 @@ from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] -class Pig(BaseModel): +class Pig(RootModel[Union[BasquePig, DanishPig]]): """ Pig """ - # data type: BasquePig - oneof_schema_1_validator: Optional[BasquePig] = None - # data type: DanishPig - oneof_schema_2_validator: Optional[DanishPig] = None - actual_instance: Optional[Union[BasquePig, DanishPig]] = None - one_of_schemas: Set[str] = { "BasquePig", "DanishPig" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[BasquePig, DanishPig] = Field( + ..., discriminator="class_name" ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - discriminator_value_class_map: Dict[str, str] = { - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = Pig.model_construct() - error_messages = [] - match = 0 - # validate data type: BasquePig - if not isinstance(v, BasquePig): - error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") - else: - match += 1 - # validate data type: DanishPig - if not isinstance(v, DanishPig): - error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into BasquePig - try: - instance.actual_instance = BasquePig.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into DanishPig - try: - instance.actual_instance = DanishPig.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], BasquePig, DanishPig]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py index 00bd38659577..bed85efa276c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.type import Type from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PonySizes(BaseModel): """ @@ -37,52 +38,27 @@ class PonySizes(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PonySizes from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PonySizes from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "type": obj.get("type") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py index 047cf0d481a9..8f972d517236 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PoopCleaning(BaseModel): """ PoopCleaning """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning'] = Field( + ..., + description="task_name of the PoopCleaning", + alias="task_name" + ) + function_name: Literal['care'] = Field( + ..., + description="function_name of the PoopCleaning", + alias="function_name" + ) content: StrictStr __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -52,54 +61,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PoopCleaning from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PoopCleaning from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py index 5a7065597861..a811f9d7c3f2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.base_discriminator import BaseDiscriminator from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PrimitiveString(BaseDiscriminator): """ @@ -37,53 +38,27 @@ class PrimitiveString(BaseDiscriminator): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PrimitiveString from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PrimitiveString from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_typeName": obj.get("_typeName"), - "_value": obj.get("_value") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py index 940016a86a72..135c6a6860b4 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PropertyMap(BaseModel): """ @@ -37,64 +38,27 @@ class PropertyMap(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PropertyMap from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) - _field_dict = {} - if self.some_data: - for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - _dict['some_data'] = _field_dict - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PropertyMap from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "some_data": dict( - (_k, Tag.from_dict(_v)) - for _k, _v in obj["some_data"].items() - ) - if obj.get("some_data") is not None - else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py index 0eb56422b648..1dca692c008d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PropertyNameCollision(BaseModel): """ @@ -38,54 +39,27 @@ class PropertyNameCollision(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PropertyNameCollision from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PropertyNameCollision from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_type": obj.get("_type"), - "type": obj.get("type"), - "type_": obj.get("type_") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py index c9f4fc6c0df9..174d6b75a6ad 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ReadOnlyFirst(BaseModel): """ @@ -37,55 +38,27 @@ class ReadOnlyFirst(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReadOnlyFirst from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - """ - excluded_fields: Set[str] = set([ - "bar", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReadOnlyFirst from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar"), - "baz": obj.get("baz") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py index 854749b4fb13..7017d2434765 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SecondCircularAllOfRef(BaseModel): """ @@ -37,61 +38,28 @@ class SecondCircularAllOfRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SecondCircularAllOfRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in circular_all_of_ref (list) - _items = [] - if self.circular_all_of_ref: - for _item_circular_all_of_ref in self.circular_all_of_ref: - if _item_circular_all_of_ref: - _items.append(_item_circular_all_of_ref.to_dict()) - _dict['circularAllOfRef'] = _items - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SecondCircularAllOfRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name"), - "circularAllOfRef": [CircularAllOfRef.from_dict(_item) for _item in obj["circularAllOfRef"]] if obj.get("circularAllOfRef") is not None else None - }) - return _obj from petstore_api.models.circular_all_of_ref import CircularAllOfRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py index c6627cf0ba63..fb545192214a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SecondRef(BaseModel): """ @@ -37,57 +38,28 @@ class SecondRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SecondRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of circular_ref - if self.circular_ref: - _dict['circular_ref'] = self.circular_ref.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SecondRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "circular_ref": CircularReferenceModel.from_dict(obj["circular_ref"]) if obj.get("circular_ref") is not None else None - }) - return _obj from petstore_api.models.circular_reference_model import CircularReferenceModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py index 7c145db0d3ae..deabec983d4f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SelfReferenceModel(BaseModel): """ @@ -37,57 +38,28 @@ class SelfReferenceModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SelfReferenceModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested - if self.nested: - _dict['nested'] = self.nested.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SelfReferenceModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested": DummyModel.from_dict(obj["nested"]) if obj.get("nested") is not None else None - }) - return _obj from petstore_api.models.dummy_model import DummyModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py index 0336e24d17da..90861e4568ae 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SpecialModelName(BaseModel): """ @@ -36,52 +37,27 @@ class SpecialModelName(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SpecialModelName from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SpecialModelName from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "$special[property.name]": obj.get("$special[property.name]") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py index d3c8f6185683..370785af0987 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.category import Category from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SpecialName(BaseModel): """ @@ -29,7 +30,10 @@ class SpecialName(BaseModel): """ # noqa: E501 var_property: Optional[StrictInt] = Field(default=None, alias="property") var_async: Optional[Category] = Field(default=None, alias="async") - var_schema: Optional[StrictStr] = Field(default=None, description="pet status in the store", alias="schema") + var_schema: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) __properties: ClassVar[List[str]] = ["property", "async", "schema"] @field_validator('var_schema') @@ -49,57 +53,27 @@ def var_schema_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SpecialName from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of var_async - if self.var_async: - _dict['async'] = self.var_async.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SpecialName from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "property": obj.get("property"), - "async": Category.from_dict(obj["async"]) if obj.get("async") is not None else None, - "schema": obj.get("schema") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py index e5ddcbcd4a74..575db976ade6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tag(BaseModel): """ @@ -37,53 +38,27 @@ class Tag(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tag from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tag from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py index 312b2c8ee473..18d6282e2c05 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py @@ -22,7 +22,8 @@ from uuid import UUID from petstore_api.models.task_activity import TaskActivity from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Task(BaseModel): """ @@ -39,56 +40,27 @@ class Task(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Task from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of activity - if self.activity: - _dict['activity'] = self.activity.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Task from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "activity": TaskActivity.from_dict(obj["activity"]) if obj.get("activity") is not None else None - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py index cc1e1fc5a60f..39a1c0bbc375 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py @@ -20,132 +20,55 @@ from petstore_api.models.bathing import Bathing from petstore_api.models.feeding import Feeding from petstore_api.models.poop_cleaning import PoopCleaning -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] -class TaskActivity(BaseModel): +class TaskActivity(RootModel[Union[Bathing, Feeding, PoopCleaning]]): """ TaskActivity """ - # data type: PoopCleaning - oneof_schema_1_validator: Optional[PoopCleaning] = None - # data type: Feeding - oneof_schema_2_validator: Optional[Feeding] = None - # data type: Bathing - oneof_schema_3_validator: Optional[Bathing] = None - actual_instance: Optional[Union[Bathing, Feeding, PoopCleaning]] = None - one_of_schemas: Set[str] = { "Bathing", "Feeding", "PoopCleaning" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[Bathing, Feeding, PoopCleaning] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = TaskActivity.model_construct() - error_messages = [] - match = 0 - # validate data type: PoopCleaning - if not isinstance(v, PoopCleaning): - error_messages.append(f"Error! Input type `{type(v)}` is not `PoopCleaning`") - else: - match += 1 - # validate data type: Feeding - if not isinstance(v, Feeding): - error_messages.append(f"Error! Input type `{type(v)}` is not `Feeding`") - else: - match += 1 - # validate data type: Bathing - if not isinstance(v, Bathing): - error_messages.append(f"Error! Input type `{type(v)}` is not `Bathing`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into PoopCleaning - try: - instance.actual_instance = PoopCleaning.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Feeding - try: - instance.actual_instance = Feeding.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Bathing - try: - instance.actual_instance = Bathing.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], Bathing, Feeding, PoopCleaning]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py index cba4ab845e5e..622dc55b5ecc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestErrorResponsesWithModel400Response(BaseModel): """ @@ -36,52 +37,27 @@ class TestErrorResponsesWithModel400Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel400Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "reason400": obj.get("reason400") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py index 787ca11942ab..ea5be0d8c54e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestErrorResponsesWithModel404Response(BaseModel): """ @@ -36,52 +37,27 @@ class TestErrorResponsesWithModel404Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel404Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "reason404": obj.get("reason404") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py index 7b93d84864f2..b8ae3f003698 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): """ @@ -37,64 +38,27 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "someProperty": obj.get("someProperty") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py index 218fa8f16d22..ac92886923bf 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py @@ -22,7 +22,8 @@ from petstore_api.models.test_enum import TestEnum from petstore_api.models.test_enum_with_default import TestEnumWithDefault from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestModelWithEnumDefault(BaseModel): """ @@ -32,7 +33,10 @@ class TestModelWithEnumDefault(BaseModel): test_string: Optional[StrictStr] = None test_enum_with_default: Optional[TestEnumWithDefault] = TestEnumWithDefault.ZWEI test_string_with_default: Optional[StrictStr] = 'ahoy matey' - test_inline_defined_enum_with_default: Optional[StrictStr] = 'B' + test_inline_defined_enum_with_default: Optional[Literal['A', 'B', 'C']] = Field( + None, + description="test_inline_defined_enum_with_default of the TestModelWithEnumDefault" + ) __properties: ClassVar[List[str]] = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"] @field_validator('test_inline_defined_enum_with_default') @@ -52,56 +56,27 @@ def test_inline_defined_enum_with_default_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestModelWithEnumDefault from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestModelWithEnumDefault from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "test_enum": obj.get("test_enum"), - "test_string": obj.get("test_string"), - "test_enum_with_default": obj.get("test_enum_with_default") if obj.get("test_enum_with_default") is not None else TestEnumWithDefault.ZWEI, - "test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey', - "test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B' - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py index a5c3bfdbb1b5..26432529a3c8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestObjectForMultipartRequestsRequestMarker(BaseModel): """ @@ -36,52 +37,27 @@ class TestObjectForMultipartRequestsRequestMarker(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestObjectForMultipartRequestsRequestMarker from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py index bf8cbf0596ae..3b2ffcf9d159 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tiger(BaseModel): """ @@ -36,52 +37,27 @@ class Tiger(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tiger from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tiger from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "skill": obj.get("skill") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index e50edf2efa85..07103b7095d6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UnnamedDictWithAdditionalModelListProperties(BaseModel): """ @@ -37,68 +38,27 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) - _field_dict_of_array = {} - if self.dict_property: - for _key_dict_property in self.dict_property: - if self.dict_property[_key_dict_property] is not None: - _field_dict_of_array[_key_dict_property] = [ - _item.to_dict() for _item in self.dict_property[_key_dict_property] - ] - _dict['dictProperty'] = _field_dict_of_array - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "dictProperty": dict( - (_k, - [CreatureInfo.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("dictProperty", {}).items() - ) - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 477dcae27c7c..cf92d499f17b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UnnamedDictWithAdditionalStringListProperties(BaseModel): """ @@ -36,52 +37,27 @@ class UnnamedDictWithAdditionalStringListProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "dictProperty": obj.get("dictProperty") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py index 9040618ac0d7..6d5c954aa65d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UploadFileWithAdditionalPropertiesRequestObject(BaseModel): """ @@ -36,52 +37,27 @@ class UploadFileWithAdditionalPropertiesRequestObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UploadFileWithAdditionalPropertiesRequestObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UploadFileWithAdditionalPropertiesRequestObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py index 45e0a66f89dd..5567c69c2c64 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class User(BaseModel): """ @@ -43,59 +44,27 @@ class User(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of User from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) + def to_dict(self) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - return _dict + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of User from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "username": obj.get("username"), - "firstName": obj.get("firstName"), - "lastName": obj.get("lastName"), - "email": obj.get("email"), - "password": obj.get("password"), - "phone": obj.get("phone"), - "userStatus": obj.get("userStatus") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py index f2cd8b7a3a30..7f800931c63b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py @@ -22,7 +22,8 @@ from petstore_api.models.one_of_enum_string import OneOfEnumString from petstore_api.models.pig import Pig from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class WithNestedOneOf(BaseModel): """ @@ -40,57 +41,27 @@ class WithNestedOneOf(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of WithNestedOneOf from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - """ - excluded_fields: Set[str] = set([ - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested_pig - if self.nested_pig: - _dict['nested_pig'] = self.nested_pig.to_dict() - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of WithNestedOneOf from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested_pig": Pig.from_dict(obj["nested_pig"]) if obj.get("nested_pig") is not None else None, - "nested_oneof_enum_string": obj.get("nested_oneof_enum_string") - }) - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesAnyType.md b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesAnyType.md index 314cba3a614c..b94c1e6d7d19 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesAnyType.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesAnyType.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_any_type import AdditionalPropert # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesAnyType from a JSON string -additional_properties_any_type_instance = AdditionalPropertiesAnyType.from_json(json) +additional_properties_any_type_instance = AdditionalPropertiesAnyType.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesAnyType.to_json()) +print(additional_properties_any_type_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_any_type_dict = additional_properties_any_type_instance.to_dict() +additional_properties_any_type_dict = additional_properties_any_type_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesAnyType from a dict -additional_properties_any_type_from_dict = AdditionalPropertiesAnyType.from_dict(additional_properties_any_type_dict) +additional_properties_any_type_from_dict = AdditionalPropertiesAnyType.model_validate(additional_properties_any_type_dict) ``` [[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-lazyImports/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesClass.md index 8d4c08707f55..4c880d6853e8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesClass.md @@ -16,14 +16,14 @@ from petstore_api.models.additional_properties_class import AdditionalProperties # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesClass from a JSON string -additional_properties_class_instance = AdditionalPropertiesClass.from_json(json) +additional_properties_class_instance = AdditionalPropertiesClass.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesClass.to_json()) +print(additional_properties_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_class_dict = additional_properties_class_instance.to_dict() +additional_properties_class_dict = additional_properties_class_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesClass from a dict -additional_properties_class_from_dict = AdditionalPropertiesClass.from_dict(additional_properties_class_dict) +additional_properties_class_from_dict = AdditionalPropertiesClass.model_validate(additional_properties_class_dict) ``` [[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-lazyImports/docs/AdditionalPropertiesObject.md b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesObject.md index d647ec64896f..bf6743709338 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesObject.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesObject.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_object import AdditionalPropertie # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesObject from a JSON string -additional_properties_object_instance = AdditionalPropertiesObject.from_json(json) +additional_properties_object_instance = AdditionalPropertiesObject.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesObject.to_json()) +print(additional_properties_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_object_dict = additional_properties_object_instance.to_dict() +additional_properties_object_dict = additional_properties_object_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesObject from a dict -additional_properties_object_from_dict = AdditionalPropertiesObject.from_dict(additional_properties_object_dict) +additional_properties_object_from_dict = AdditionalPropertiesObject.model_validate(additional_properties_object_dict) ``` [[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-lazyImports/docs/AdditionalPropertiesWithDescriptionOnly.md b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesWithDescriptionOnly.md index 061f5524872b..1cb2a02f7584 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesWithDescriptionOnly.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/AdditionalPropertiesWithDescriptionOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_with_description_only import Addi # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string -additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.from_json(json) +additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesWithDescriptionOnly.to_json()) +print(additional_properties_with_description_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.to_dict() +additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesWithDescriptionOnly from a dict -additional_properties_with_description_only_from_dict = AdditionalPropertiesWithDescriptionOnly.from_dict(additional_properties_with_description_only_dict) +additional_properties_with_description_only_from_dict = AdditionalPropertiesWithDescriptionOnly.model_validate(additional_properties_with_description_only_dict) ``` [[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-lazyImports/docs/AllOfSuperModel.md b/samples/openapi3/client/petstore/python-lazyImports/docs/AllOfSuperModel.md index 421a1527f1ef..88cb95097517 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/AllOfSuperModel.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/AllOfSuperModel.md @@ -15,14 +15,14 @@ from petstore_api.models.all_of_super_model import AllOfSuperModel # TODO update the JSON string below json = "{}" # create an instance of AllOfSuperModel from a JSON string -all_of_super_model_instance = AllOfSuperModel.from_json(json) +all_of_super_model_instance = AllOfSuperModel.model_validate_json(json) # print the JSON string representation of the object -print(AllOfSuperModel.to_json()) +print(all_of_super_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -all_of_super_model_dict = all_of_super_model_instance.to_dict() +all_of_super_model_dict = all_of_super_model_instance.model_dump(by_alias=True) # create an instance of AllOfSuperModel from a dict -all_of_super_model_from_dict = AllOfSuperModel.from_dict(all_of_super_model_dict) +all_of_super_model_from_dict = AllOfSuperModel.model_validate(all_of_super_model_dict) ``` [[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-lazyImports/docs/AllOfWithSingleRef.md b/samples/openapi3/client/petstore/python-lazyImports/docs/AllOfWithSingleRef.md index 203a4b5da3d5..dd0f755dfe65 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/AllOfWithSingleRef.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/AllOfWithSingleRef.md @@ -16,14 +16,14 @@ from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef # TODO update the JSON string below json = "{}" # create an instance of AllOfWithSingleRef from a JSON string -all_of_with_single_ref_instance = AllOfWithSingleRef.from_json(json) +all_of_with_single_ref_instance = AllOfWithSingleRef.model_validate_json(json) # print the JSON string representation of the object -print(AllOfWithSingleRef.to_json()) +print(all_of_with_single_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -all_of_with_single_ref_dict = all_of_with_single_ref_instance.to_dict() +all_of_with_single_ref_dict = all_of_with_single_ref_instance.model_dump(by_alias=True) # create an instance of AllOfWithSingleRef from a dict -all_of_with_single_ref_from_dict = AllOfWithSingleRef.from_dict(all_of_with_single_ref_dict) +all_of_with_single_ref_from_dict = AllOfWithSingleRef.model_validate(all_of_with_single_ref_dict) ``` [[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-lazyImports/docs/Animal.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Animal.md index 381d27b66e44..fcded75f52be 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Animal.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Animal.md @@ -16,14 +16,14 @@ from petstore_api.models.animal import Animal # TODO update the JSON string below json = "{}" # create an instance of Animal from a JSON string -animal_instance = Animal.from_json(json) +animal_instance = Animal.model_validate_json(json) # print the JSON string representation of the object -print(Animal.to_json()) +print(animal_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -animal_dict = animal_instance.to_dict() +animal_dict = animal_instance.model_dump(by_alias=True) # create an instance of Animal from a dict -animal_from_dict = Animal.from_dict(animal_dict) +animal_from_dict = Animal.model_validate(animal_dict) ``` [[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-lazyImports/docs/AnyOfColor.md b/samples/openapi3/client/petstore/python-lazyImports/docs/AnyOfColor.md index 6ed75dd7b48a..02aab883b2b0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/AnyOfColor.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/AnyOfColor.md @@ -15,14 +15,14 @@ from petstore_api.models.any_of_color import AnyOfColor # TODO update the JSON string below json = "{}" # create an instance of AnyOfColor from a JSON string -any_of_color_instance = AnyOfColor.from_json(json) +any_of_color_instance = AnyOfColor.model_validate_json(json) # print the JSON string representation of the object -print(AnyOfColor.to_json()) +print(any_of_color_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -any_of_color_dict = any_of_color_instance.to_dict() +any_of_color_dict = any_of_color_instance.model_dump(by_alias=True) # create an instance of AnyOfColor from a dict -any_of_color_from_dict = AnyOfColor.from_dict(any_of_color_dict) +any_of_color_from_dict = AnyOfColor.model_validate(any_of_color_dict) ``` [[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-lazyImports/docs/AnyOfPig.md b/samples/openapi3/client/petstore/python-lazyImports/docs/AnyOfPig.md index 9367e2261898..db2878121f29 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/AnyOfPig.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/AnyOfPig.md @@ -17,14 +17,14 @@ from petstore_api.models.any_of_pig import AnyOfPig # TODO update the JSON string below json = "{}" # create an instance of AnyOfPig from a JSON string -any_of_pig_instance = AnyOfPig.from_json(json) +any_of_pig_instance = AnyOfPig.model_validate_json(json) # print the JSON string representation of the object -print(AnyOfPig.to_json()) +print(any_of_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -any_of_pig_dict = any_of_pig_instance.to_dict() +any_of_pig_dict = any_of_pig_instance.model_dump(by_alias=True) # create an instance of AnyOfPig from a dict -any_of_pig_from_dict = AnyOfPig.from_dict(any_of_pig_dict) +any_of_pig_from_dict = AnyOfPig.model_validate(any_of_pig_dict) ``` [[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-lazyImports/docs/ArrayOfArrayOfModel.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfArrayOfModel.md index f866863d53f9..e8274d8fbb52 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfArrayOfModel.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfArrayOfModel.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel # TODO update the JSON string below json = "{}" # create an instance of ArrayOfArrayOfModel from a JSON string -array_of_array_of_model_instance = ArrayOfArrayOfModel.from_json(json) +array_of_array_of_model_instance = ArrayOfArrayOfModel.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfArrayOfModel.to_json()) +print(array_of_array_of_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_array_of_model_dict = array_of_array_of_model_instance.to_dict() +array_of_array_of_model_dict = array_of_array_of_model_instance.model_dump(by_alias=True) # create an instance of ArrayOfArrayOfModel from a dict -array_of_array_of_model_from_dict = ArrayOfArrayOfModel.from_dict(array_of_array_of_model_dict) +array_of_array_of_model_from_dict = ArrayOfArrayOfModel.model_validate(array_of_array_of_model_dict) ``` [[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-lazyImports/docs/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfArrayOfNumberOnly.md index 32bd2dfbf1e2..8931a1c7e467 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfArrayOfNumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb # TODO update the JSON string below json = "{}" # create an instance of ArrayOfArrayOfNumberOnly from a JSON string -array_of_array_of_number_only_instance = ArrayOfArrayOfNumberOnly.from_json(json) +array_of_array_of_number_only_instance = ArrayOfArrayOfNumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfArrayOfNumberOnly.to_json()) +print(array_of_array_of_number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_array_of_number_only_dict = array_of_array_of_number_only_instance.to_dict() +array_of_array_of_number_only_dict = array_of_array_of_number_only_instance.model_dump(by_alias=True) # create an instance of ArrayOfArrayOfNumberOnly from a dict -array_of_array_of_number_only_from_dict = ArrayOfArrayOfNumberOnly.from_dict(array_of_array_of_number_only_dict) +array_of_array_of_number_only_from_dict = ArrayOfArrayOfNumberOnly.model_validate(array_of_array_of_number_only_dict) ``` [[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-lazyImports/docs/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfNumberOnly.md index b814d7594942..a709583be699 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayOfNumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_number_only import ArrayOfNumberOnly # TODO update the JSON string below json = "{}" # create an instance of ArrayOfNumberOnly from a JSON string -array_of_number_only_instance = ArrayOfNumberOnly.from_json(json) +array_of_number_only_instance = ArrayOfNumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfNumberOnly.to_json()) +print(array_of_number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_number_only_dict = array_of_number_only_instance.to_dict() +array_of_number_only_dict = array_of_number_only_instance.model_dump(by_alias=True) # create an instance of ArrayOfNumberOnly from a dict -array_of_number_only_from_dict = ArrayOfNumberOnly.from_dict(array_of_number_only_dict) +array_of_number_only_from_dict = ArrayOfNumberOnly.model_validate(array_of_number_only_dict) ``` [[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-lazyImports/docs/ArrayTest.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayTest.md index ed871fae662d..a99eb056c5ca 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayTest.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ArrayTest.md @@ -18,14 +18,14 @@ from petstore_api.models.array_test import ArrayTest # TODO update the JSON string below json = "{}" # create an instance of ArrayTest from a JSON string -array_test_instance = ArrayTest.from_json(json) +array_test_instance = ArrayTest.model_validate_json(json) # print the JSON string representation of the object -print(ArrayTest.to_json()) +print(array_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_test_dict = array_test_instance.to_dict() +array_test_dict = array_test_instance.model_dump(by_alias=True) # create an instance of ArrayTest from a dict -array_test_from_dict = ArrayTest.from_dict(array_test_dict) +array_test_from_dict = ArrayTest.model_validate(array_test_dict) ``` [[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-lazyImports/docs/BaseDiscriminator.md b/samples/openapi3/client/petstore/python-lazyImports/docs/BaseDiscriminator.md index fcdbeb032e68..0482396cbcf8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/BaseDiscriminator.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/BaseDiscriminator.md @@ -15,14 +15,14 @@ from petstore_api.models.base_discriminator import BaseDiscriminator # TODO update the JSON string below json = "{}" # create an instance of BaseDiscriminator from a JSON string -base_discriminator_instance = BaseDiscriminator.from_json(json) +base_discriminator_instance = BaseDiscriminator.model_validate_json(json) # print the JSON string representation of the object -print(BaseDiscriminator.to_json()) +print(base_discriminator_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -base_discriminator_dict = base_discriminator_instance.to_dict() +base_discriminator_dict = base_discriminator_instance.model_dump(by_alias=True) # create an instance of BaseDiscriminator from a dict -base_discriminator_from_dict = BaseDiscriminator.from_dict(base_discriminator_dict) +base_discriminator_from_dict = BaseDiscriminator.model_validate(base_discriminator_dict) ``` [[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-lazyImports/docs/BasquePig.md b/samples/openapi3/client/petstore/python-lazyImports/docs/BasquePig.md index ee28d628722f..9844d05b3740 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/BasquePig.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/BasquePig.md @@ -16,14 +16,14 @@ from petstore_api.models.basque_pig import BasquePig # TODO update the JSON string below json = "{}" # create an instance of BasquePig from a JSON string -basque_pig_instance = BasquePig.from_json(json) +basque_pig_instance = BasquePig.model_validate_json(json) # print the JSON string representation of the object -print(BasquePig.to_json()) +print(basque_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -basque_pig_dict = basque_pig_instance.to_dict() +basque_pig_dict = basque_pig_instance.model_dump(by_alias=True) # create an instance of BasquePig from a dict -basque_pig_from_dict = BasquePig.from_dict(basque_pig_dict) +basque_pig_from_dict = BasquePig.model_validate(basque_pig_dict) ``` [[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-lazyImports/docs/Bathing.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Bathing.md index 6ad70e2f67cc..2c8d8332629b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Bathing.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Bathing.md @@ -17,14 +17,14 @@ from petstore_api.models.bathing import Bathing # TODO update the JSON string below json = "{}" # create an instance of Bathing from a JSON string -bathing_instance = Bathing.from_json(json) +bathing_instance = Bathing.model_validate_json(json) # print the JSON string representation of the object -print(Bathing.to_json()) +print(bathing_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -bathing_dict = bathing_instance.to_dict() +bathing_dict = bathing_instance.model_dump(by_alias=True) # create an instance of Bathing from a dict -bathing_from_dict = Bathing.from_dict(bathing_dict) +bathing_from_dict = Bathing.model_validate(bathing_dict) ``` [[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-lazyImports/docs/Capitalization.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Capitalization.md index 6f564a8ed8c9..55fcc0c01cb2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Capitalization.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Capitalization.md @@ -20,14 +20,14 @@ from petstore_api.models.capitalization import Capitalization # TODO update the JSON string below json = "{}" # create an instance of Capitalization from a JSON string -capitalization_instance = Capitalization.from_json(json) +capitalization_instance = Capitalization.model_validate_json(json) # print the JSON string representation of the object -print(Capitalization.to_json()) +print(capitalization_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -capitalization_dict = capitalization_instance.to_dict() +capitalization_dict = capitalization_instance.model_dump(by_alias=True) # create an instance of Capitalization from a dict -capitalization_from_dict = Capitalization.from_dict(capitalization_dict) +capitalization_from_dict = Capitalization.model_validate(capitalization_dict) ``` [[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-lazyImports/docs/Cat.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Cat.md index d0e39efdb33e..0845d68bd487 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Cat.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Cat.md @@ -15,14 +15,14 @@ from petstore_api.models.cat import Cat # TODO update the JSON string below json = "{}" # create an instance of Cat from a JSON string -cat_instance = Cat.from_json(json) +cat_instance = Cat.model_validate_json(json) # print the JSON string representation of the object -print(Cat.to_json()) +print(cat_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -cat_dict = cat_instance.to_dict() +cat_dict = cat_instance.model_dump(by_alias=True) # create an instance of Cat from a dict -cat_from_dict = Cat.from_dict(cat_dict) +cat_from_dict = Cat.model_validate(cat_dict) ``` [[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-lazyImports/docs/Category.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Category.md index dbde14b7344c..8a14791c7925 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Category.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Category.md @@ -16,14 +16,14 @@ from petstore_api.models.category import Category # TODO update the JSON string below json = "{}" # create an instance of Category from a JSON string -category_instance = Category.from_json(json) +category_instance = Category.model_validate_json(json) # print the JSON string representation of the object -print(Category.to_json()) +print(category_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -category_dict = category_instance.to_dict() +category_dict = category_instance.model_dump(by_alias=True) # create an instance of Category from a dict -category_from_dict = Category.from_dict(category_dict) +category_from_dict = Category.model_validate(category_dict) ``` [[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-lazyImports/docs/CircularAllOfRef.md b/samples/openapi3/client/petstore/python-lazyImports/docs/CircularAllOfRef.md index 65b171177e58..f937a53cfe3c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/CircularAllOfRef.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/CircularAllOfRef.md @@ -16,14 +16,14 @@ from petstore_api.models.circular_all_of_ref import CircularAllOfRef # TODO update the JSON string below json = "{}" # create an instance of CircularAllOfRef from a JSON string -circular_all_of_ref_instance = CircularAllOfRef.from_json(json) +circular_all_of_ref_instance = CircularAllOfRef.model_validate_json(json) # print the JSON string representation of the object -print(CircularAllOfRef.to_json()) +print(circular_all_of_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -circular_all_of_ref_dict = circular_all_of_ref_instance.to_dict() +circular_all_of_ref_dict = circular_all_of_ref_instance.model_dump(by_alias=True) # create an instance of CircularAllOfRef from a dict -circular_all_of_ref_from_dict = CircularAllOfRef.from_dict(circular_all_of_ref_dict) +circular_all_of_ref_from_dict = CircularAllOfRef.model_validate(circular_all_of_ref_dict) ``` [[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-lazyImports/docs/CircularReferenceModel.md b/samples/openapi3/client/petstore/python-lazyImports/docs/CircularReferenceModel.md index 87216f7273ab..9a39f46e5d7d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/CircularReferenceModel.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/CircularReferenceModel.md @@ -16,14 +16,14 @@ from petstore_api.models.circular_reference_model import CircularReferenceModel # TODO update the JSON string below json = "{}" # create an instance of CircularReferenceModel from a JSON string -circular_reference_model_instance = CircularReferenceModel.from_json(json) +circular_reference_model_instance = CircularReferenceModel.model_validate_json(json) # print the JSON string representation of the object -print(CircularReferenceModel.to_json()) +print(circular_reference_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -circular_reference_model_dict = circular_reference_model_instance.to_dict() +circular_reference_model_dict = circular_reference_model_instance.model_dump(by_alias=True) # create an instance of CircularReferenceModel from a dict -circular_reference_model_from_dict = CircularReferenceModel.from_dict(circular_reference_model_dict) +circular_reference_model_from_dict = CircularReferenceModel.model_validate(circular_reference_model_dict) ``` [[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-lazyImports/docs/ClassModel.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ClassModel.md index ea76a5c157bf..50fbfefa7661 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ClassModel.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ClassModel.md @@ -16,14 +16,14 @@ from petstore_api.models.class_model import ClassModel # TODO update the JSON string below json = "{}" # create an instance of ClassModel from a JSON string -class_model_instance = ClassModel.from_json(json) +class_model_instance = ClassModel.model_validate_json(json) # print the JSON string representation of the object -print(ClassModel.to_json()) +print(class_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -class_model_dict = class_model_instance.to_dict() +class_model_dict = class_model_instance.model_dump(by_alias=True) # create an instance of ClassModel from a dict -class_model_from_dict = ClassModel.from_dict(class_model_dict) +class_model_from_dict = ClassModel.model_validate(class_model_dict) ``` [[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-lazyImports/docs/Client.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Client.md index 22321c189150..160a80da457f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Client.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Client.md @@ -15,14 +15,14 @@ from petstore_api.models.client import Client # TODO update the JSON string below json = "{}" # create an instance of Client from a JSON string -client_instance = Client.from_json(json) +client_instance = Client.model_validate_json(json) # print the JSON string representation of the object -print(Client.to_json()) +print(client_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -client_dict = client_instance.to_dict() +client_dict = client_instance.model_dump(by_alias=True) # create an instance of Client from a dict -client_from_dict = Client.from_dict(client_dict) +client_from_dict = Client.model_validate(client_dict) ``` [[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-lazyImports/docs/Color.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Color.md index 9ac3ab2e91f4..1425ff185040 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Color.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Color.md @@ -15,14 +15,14 @@ from petstore_api.models.color import Color # TODO update the JSON string below json = "{}" # create an instance of Color from a JSON string -color_instance = Color.from_json(json) +color_instance = Color.model_validate_json(json) # print the JSON string representation of the object -print(Color.to_json()) +print(color_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -color_dict = color_instance.to_dict() +color_dict = color_instance.model_dump(by_alias=True) # create an instance of Color from a dict -color_from_dict = Color.from_dict(color_dict) +color_from_dict = Color.model_validate(color_dict) ``` [[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-lazyImports/docs/Creature.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Creature.md index a4710214c198..eb0ba3b2f127 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Creature.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Creature.md @@ -16,14 +16,14 @@ from petstore_api.models.creature import Creature # TODO update the JSON string below json = "{}" # create an instance of Creature from a JSON string -creature_instance = Creature.from_json(json) +creature_instance = Creature.model_validate_json(json) # print the JSON string representation of the object -print(Creature.to_json()) +print(creature_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -creature_dict = creature_instance.to_dict() +creature_dict = creature_instance.model_dump(by_alias=True) # create an instance of Creature from a dict -creature_from_dict = Creature.from_dict(creature_dict) +creature_from_dict = Creature.model_validate(creature_dict) ``` [[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-lazyImports/docs/CreatureInfo.md b/samples/openapi3/client/petstore/python-lazyImports/docs/CreatureInfo.md index db3b82bb9ff5..156d93939201 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/CreatureInfo.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/CreatureInfo.md @@ -15,14 +15,14 @@ from petstore_api.models.creature_info import CreatureInfo # TODO update the JSON string below json = "{}" # create an instance of CreatureInfo from a JSON string -creature_info_instance = CreatureInfo.from_json(json) +creature_info_instance = CreatureInfo.model_validate_json(json) # print the JSON string representation of the object -print(CreatureInfo.to_json()) +print(creature_info_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -creature_info_dict = creature_info_instance.to_dict() +creature_info_dict = creature_info_instance.model_dump(by_alias=True) # create an instance of CreatureInfo from a dict -creature_info_from_dict = CreatureInfo.from_dict(creature_info_dict) +creature_info_from_dict = CreatureInfo.model_validate(creature_info_dict) ``` [[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-lazyImports/docs/DanishPig.md b/samples/openapi3/client/petstore/python-lazyImports/docs/DanishPig.md index 16941388832a..5eac27f79e79 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/DanishPig.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/DanishPig.md @@ -16,14 +16,14 @@ from petstore_api.models.danish_pig import DanishPig # TODO update the JSON string below json = "{}" # create an instance of DanishPig from a JSON string -danish_pig_instance = DanishPig.from_json(json) +danish_pig_instance = DanishPig.model_validate_json(json) # print the JSON string representation of the object -print(DanishPig.to_json()) +print(danish_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -danish_pig_dict = danish_pig_instance.to_dict() +danish_pig_dict = danish_pig_instance.model_dump(by_alias=True) # create an instance of DanishPig from a dict -danish_pig_from_dict = DanishPig.from_dict(danish_pig_dict) +danish_pig_from_dict = DanishPig.model_validate(danish_pig_dict) ``` [[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-lazyImports/docs/DeprecatedObject.md b/samples/openapi3/client/petstore/python-lazyImports/docs/DeprecatedObject.md index 6b362f379ba4..ff3aa9812e2d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/DeprecatedObject.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/DeprecatedObject.md @@ -15,14 +15,14 @@ from petstore_api.models.deprecated_object import DeprecatedObject # TODO update the JSON string below json = "{}" # create an instance of DeprecatedObject from a JSON string -deprecated_object_instance = DeprecatedObject.from_json(json) +deprecated_object_instance = DeprecatedObject.model_validate_json(json) # print the JSON string representation of the object -print(DeprecatedObject.to_json()) +print(deprecated_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -deprecated_object_dict = deprecated_object_instance.to_dict() +deprecated_object_dict = deprecated_object_instance.model_dump(by_alias=True) # create an instance of DeprecatedObject from a dict -deprecated_object_from_dict = DeprecatedObject.from_dict(deprecated_object_dict) +deprecated_object_from_dict = DeprecatedObject.model_validate(deprecated_object_dict) ``` [[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-lazyImports/docs/DiscriminatorAllOfSub.md b/samples/openapi3/client/petstore/python-lazyImports/docs/DiscriminatorAllOfSub.md index f72b6e8e68ca..aa7af45b99fa 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/DiscriminatorAllOfSub.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/DiscriminatorAllOfSub.md @@ -14,14 +14,14 @@ from petstore_api.models.discriminator_all_of_sub import DiscriminatorAllOfSub # TODO update the JSON string below json = "{}" # create an instance of DiscriminatorAllOfSub from a JSON string -discriminator_all_of_sub_instance = DiscriminatorAllOfSub.from_json(json) +discriminator_all_of_sub_instance = DiscriminatorAllOfSub.model_validate_json(json) # print the JSON string representation of the object -print(DiscriminatorAllOfSub.to_json()) +print(discriminator_all_of_sub_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -discriminator_all_of_sub_dict = discriminator_all_of_sub_instance.to_dict() +discriminator_all_of_sub_dict = discriminator_all_of_sub_instance.model_dump(by_alias=True) # create an instance of DiscriminatorAllOfSub from a dict -discriminator_all_of_sub_from_dict = DiscriminatorAllOfSub.from_dict(discriminator_all_of_sub_dict) +discriminator_all_of_sub_from_dict = DiscriminatorAllOfSub.model_validate(discriminator_all_of_sub_dict) ``` [[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-lazyImports/docs/DiscriminatorAllOfSuper.md b/samples/openapi3/client/petstore/python-lazyImports/docs/DiscriminatorAllOfSuper.md index 477c05bfc446..c21e5b2296ac 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/DiscriminatorAllOfSuper.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/DiscriminatorAllOfSuper.md @@ -15,14 +15,14 @@ from petstore_api.models.discriminator_all_of_super import DiscriminatorAllOfSup # TODO update the JSON string below json = "{}" # create an instance of DiscriminatorAllOfSuper from a JSON string -discriminator_all_of_super_instance = DiscriminatorAllOfSuper.from_json(json) +discriminator_all_of_super_instance = DiscriminatorAllOfSuper.model_validate_json(json) # print the JSON string representation of the object -print(DiscriminatorAllOfSuper.to_json()) +print(discriminator_all_of_super_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -discriminator_all_of_super_dict = discriminator_all_of_super_instance.to_dict() +discriminator_all_of_super_dict = discriminator_all_of_super_instance.model_dump(by_alias=True) # create an instance of DiscriminatorAllOfSuper from a dict -discriminator_all_of_super_from_dict = DiscriminatorAllOfSuper.from_dict(discriminator_all_of_super_dict) +discriminator_all_of_super_from_dict = DiscriminatorAllOfSuper.model_validate(discriminator_all_of_super_dict) ``` [[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-lazyImports/docs/Dog.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Dog.md index ed23f613d01d..2065d42f5f6b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Dog.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Dog.md @@ -15,14 +15,14 @@ from petstore_api.models.dog import Dog # TODO update the JSON string below json = "{}" # create an instance of Dog from a JSON string -dog_instance = Dog.from_json(json) +dog_instance = Dog.model_validate_json(json) # print the JSON string representation of the object -print(Dog.to_json()) +print(dog_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -dog_dict = dog_instance.to_dict() +dog_dict = dog_instance.model_dump(by_alias=True) # create an instance of Dog from a dict -dog_from_dict = Dog.from_dict(dog_dict) +dog_from_dict = Dog.model_validate(dog_dict) ``` [[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-lazyImports/docs/DummyModel.md b/samples/openapi3/client/petstore/python-lazyImports/docs/DummyModel.md index 01b675977f58..dfe28d9f75b1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/DummyModel.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/DummyModel.md @@ -16,14 +16,14 @@ from petstore_api.models.dummy_model import DummyModel # TODO update the JSON string below json = "{}" # create an instance of DummyModel from a JSON string -dummy_model_instance = DummyModel.from_json(json) +dummy_model_instance = DummyModel.model_validate_json(json) # print the JSON string representation of the object -print(DummyModel.to_json()) +print(dummy_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -dummy_model_dict = dummy_model_instance.to_dict() +dummy_model_dict = dummy_model_instance.model_dump(by_alias=True) # create an instance of DummyModel from a dict -dummy_model_from_dict = DummyModel.from_dict(dummy_model_dict) +dummy_model_from_dict = DummyModel.model_validate(dummy_model_dict) ``` [[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-lazyImports/docs/EnumArrays.md b/samples/openapi3/client/petstore/python-lazyImports/docs/EnumArrays.md index f44617497bce..bf8b1a6cd05c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/EnumArrays.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/EnumArrays.md @@ -16,14 +16,14 @@ from petstore_api.models.enum_arrays import EnumArrays # TODO update the JSON string below json = "{}" # create an instance of EnumArrays from a JSON string -enum_arrays_instance = EnumArrays.from_json(json) +enum_arrays_instance = EnumArrays.model_validate_json(json) # print the JSON string representation of the object -print(EnumArrays.to_json()) +print(enum_arrays_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_arrays_dict = enum_arrays_instance.to_dict() +enum_arrays_dict = enum_arrays_instance.model_dump(by_alias=True) # create an instance of EnumArrays from a dict -enum_arrays_from_dict = EnumArrays.from_dict(enum_arrays_dict) +enum_arrays_from_dict = EnumArrays.model_validate(enum_arrays_dict) ``` [[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-lazyImports/docs/EnumRefWithDefaultValue.md b/samples/openapi3/client/petstore/python-lazyImports/docs/EnumRefWithDefaultValue.md index eeb0dc66969f..cbe6845479eb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/EnumRefWithDefaultValue.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/EnumRefWithDefaultValue.md @@ -15,14 +15,14 @@ from petstore_api.models.enum_ref_with_default_value import EnumRefWithDefaultVa # TODO update the JSON string below json = "{}" # create an instance of EnumRefWithDefaultValue from a JSON string -enum_ref_with_default_value_instance = EnumRefWithDefaultValue.from_json(json) +enum_ref_with_default_value_instance = EnumRefWithDefaultValue.model_validate_json(json) # print the JSON string representation of the object -print(EnumRefWithDefaultValue.to_json()) +print(enum_ref_with_default_value_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_ref_with_default_value_dict = enum_ref_with_default_value_instance.to_dict() +enum_ref_with_default_value_dict = enum_ref_with_default_value_instance.model_dump(by_alias=True) # create an instance of EnumRefWithDefaultValue from a dict -enum_ref_with_default_value_from_dict = EnumRefWithDefaultValue.from_dict(enum_ref_with_default_value_dict) +enum_ref_with_default_value_from_dict = EnumRefWithDefaultValue.model_validate(enum_ref_with_default_value_dict) ``` [[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-lazyImports/docs/EnumTest.md b/samples/openapi3/client/petstore/python-lazyImports/docs/EnumTest.md index 9f96c605d888..6ce4891aa9d5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/EnumTest.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/EnumTest.md @@ -27,14 +27,14 @@ from petstore_api.models.enum_test import EnumTest # TODO update the JSON string below json = "{}" # create an instance of EnumTest from a JSON string -enum_test_instance = EnumTest.from_json(json) +enum_test_instance = EnumTest.model_validate_json(json) # print the JSON string representation of the object -print(EnumTest.to_json()) +print(enum_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_test_dict = enum_test_instance.to_dict() +enum_test_dict = enum_test_instance.model_dump(by_alias=True) # create an instance of EnumTest from a dict -enum_test_from_dict = EnumTest.from_dict(enum_test_dict) +enum_test_from_dict = EnumTest.model_validate(enum_test_dict) ``` [[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-lazyImports/docs/Feeding.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Feeding.md index 9f92b5d964d3..773d1373cca0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Feeding.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Feeding.md @@ -17,14 +17,14 @@ from petstore_api.models.feeding import Feeding # TODO update the JSON string below json = "{}" # create an instance of Feeding from a JSON string -feeding_instance = Feeding.from_json(json) +feeding_instance = Feeding.model_validate_json(json) # print the JSON string representation of the object -print(Feeding.to_json()) +print(feeding_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -feeding_dict = feeding_instance.to_dict() +feeding_dict = feeding_instance.model_dump(by_alias=True) # create an instance of Feeding from a dict -feeding_from_dict = Feeding.from_dict(feeding_dict) +feeding_from_dict = Feeding.model_validate(feeding_dict) ``` [[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-lazyImports/docs/File.md b/samples/openapi3/client/petstore/python-lazyImports/docs/File.md index 23f0567411ce..3fe748f4f30f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/File.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/File.md @@ -16,14 +16,14 @@ from petstore_api.models.file import File # TODO update the JSON string below json = "{}" # create an instance of File from a JSON string -file_instance = File.from_json(json) +file_instance = File.model_validate_json(json) # print the JSON string representation of the object -print(File.to_json()) +print(file_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -file_dict = file_instance.to_dict() +file_dict = file_instance.model_dump(by_alias=True) # create an instance of File from a dict -file_from_dict = File.from_dict(file_dict) +file_from_dict = File.model_validate(file_dict) ``` [[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-lazyImports/docs/FileSchemaTestClass.md b/samples/openapi3/client/petstore/python-lazyImports/docs/FileSchemaTestClass.md index e1118042a8ec..78bc4ae135da 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/FileSchemaTestClass.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/FileSchemaTestClass.md @@ -16,14 +16,14 @@ from petstore_api.models.file_schema_test_class import FileSchemaTestClass # TODO update the JSON string below json = "{}" # create an instance of FileSchemaTestClass from a JSON string -file_schema_test_class_instance = FileSchemaTestClass.from_json(json) +file_schema_test_class_instance = FileSchemaTestClass.model_validate_json(json) # print the JSON string representation of the object -print(FileSchemaTestClass.to_json()) +print(file_schema_test_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -file_schema_test_class_dict = file_schema_test_class_instance.to_dict() +file_schema_test_class_dict = file_schema_test_class_instance.model_dump(by_alias=True) # create an instance of FileSchemaTestClass from a dict -file_schema_test_class_from_dict = FileSchemaTestClass.from_dict(file_schema_test_class_dict) +file_schema_test_class_from_dict = FileSchemaTestClass.model_validate(file_schema_test_class_dict) ``` [[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-lazyImports/docs/FirstRef.md b/samples/openapi3/client/petstore/python-lazyImports/docs/FirstRef.md index 94b8ddc5ac22..6da6650e5df7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/FirstRef.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/FirstRef.md @@ -16,14 +16,14 @@ from petstore_api.models.first_ref import FirstRef # TODO update the JSON string below json = "{}" # create an instance of FirstRef from a JSON string -first_ref_instance = FirstRef.from_json(json) +first_ref_instance = FirstRef.model_validate_json(json) # print the JSON string representation of the object -print(FirstRef.to_json()) +print(first_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -first_ref_dict = first_ref_instance.to_dict() +first_ref_dict = first_ref_instance.model_dump(by_alias=True) # create an instance of FirstRef from a dict -first_ref_from_dict = FirstRef.from_dict(first_ref_dict) +first_ref_from_dict = FirstRef.model_validate(first_ref_dict) ``` [[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-lazyImports/docs/Foo.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Foo.md index f635b0daa6db..c11ae111ee22 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Foo.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Foo.md @@ -15,14 +15,14 @@ from petstore_api.models.foo import Foo # TODO update the JSON string below json = "{}" # create an instance of Foo from a JSON string -foo_instance = Foo.from_json(json) +foo_instance = Foo.model_validate_json(json) # print the JSON string representation of the object -print(Foo.to_json()) +print(foo_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -foo_dict = foo_instance.to_dict() +foo_dict = foo_instance.model_dump(by_alias=True) # create an instance of Foo from a dict -foo_from_dict = Foo.from_dict(foo_dict) +foo_from_dict = Foo.model_validate(foo_dict) ``` [[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-lazyImports/docs/FooGetDefaultResponse.md b/samples/openapi3/client/petstore/python-lazyImports/docs/FooGetDefaultResponse.md index 8d84f795b00a..aaccf08bfd2e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/FooGetDefaultResponse.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/FooGetDefaultResponse.md @@ -15,14 +15,14 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse # TODO update the JSON string below json = "{}" # create an instance of FooGetDefaultResponse from a JSON string -foo_get_default_response_instance = FooGetDefaultResponse.from_json(json) +foo_get_default_response_instance = FooGetDefaultResponse.model_validate_json(json) # print the JSON string representation of the object -print(FooGetDefaultResponse.to_json()) +print(foo_get_default_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -foo_get_default_response_dict = foo_get_default_response_instance.to_dict() +foo_get_default_response_dict = foo_get_default_response_instance.model_dump(by_alias=True) # create an instance of FooGetDefaultResponse from a dict -foo_get_default_response_from_dict = FooGetDefaultResponse.from_dict(foo_get_default_response_dict) +foo_get_default_response_from_dict = FooGetDefaultResponse.model_validate(foo_get_default_response_dict) ``` [[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-lazyImports/docs/FormatTest.md b/samples/openapi3/client/petstore/python-lazyImports/docs/FormatTest.md index 714d2401bbae..98c3dc89570d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/FormatTest.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/FormatTest.md @@ -31,14 +31,14 @@ from petstore_api.models.format_test import FormatTest # TODO update the JSON string below json = "{}" # create an instance of FormatTest from a JSON string -format_test_instance = FormatTest.from_json(json) +format_test_instance = FormatTest.model_validate_json(json) # print the JSON string representation of the object -print(FormatTest.to_json()) +print(format_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -format_test_dict = format_test_instance.to_dict() +format_test_dict = format_test_instance.model_dump(by_alias=True) # create an instance of FormatTest from a dict -format_test_from_dict = FormatTest.from_dict(format_test_dict) +format_test_from_dict = FormatTest.model_validate(format_test_dict) ``` [[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-lazyImports/docs/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/python-lazyImports/docs/HasOnlyReadOnly.md index fdc48781b15a..66dca11251aa 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/HasOnlyReadOnly.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/HasOnlyReadOnly.md @@ -16,14 +16,14 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly # TODO update the JSON string below json = "{}" # create an instance of HasOnlyReadOnly from a JSON string -has_only_read_only_instance = HasOnlyReadOnly.from_json(json) +has_only_read_only_instance = HasOnlyReadOnly.model_validate_json(json) # print the JSON string representation of the object -print(HasOnlyReadOnly.to_json()) +print(has_only_read_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -has_only_read_only_dict = has_only_read_only_instance.to_dict() +has_only_read_only_dict = has_only_read_only_instance.model_dump(by_alias=True) # create an instance of HasOnlyReadOnly from a dict -has_only_read_only_from_dict = HasOnlyReadOnly.from_dict(has_only_read_only_dict) +has_only_read_only_from_dict = HasOnlyReadOnly.model_validate(has_only_read_only_dict) ``` [[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-lazyImports/docs/HealthCheckResult.md b/samples/openapi3/client/petstore/python-lazyImports/docs/HealthCheckResult.md index d4a2b187167f..522156ae5b16 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/HealthCheckResult.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/HealthCheckResult.md @@ -16,14 +16,14 @@ from petstore_api.models.health_check_result import HealthCheckResult # TODO update the JSON string below json = "{}" # create an instance of HealthCheckResult from a JSON string -health_check_result_instance = HealthCheckResult.from_json(json) +health_check_result_instance = HealthCheckResult.model_validate_json(json) # print the JSON string representation of the object -print(HealthCheckResult.to_json()) +print(health_check_result_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -health_check_result_dict = health_check_result_instance.to_dict() +health_check_result_dict = health_check_result_instance.model_dump(by_alias=True) # create an instance of HealthCheckResult from a dict -health_check_result_from_dict = HealthCheckResult.from_dict(health_check_result_dict) +health_check_result_from_dict = HealthCheckResult.model_validate(health_check_result_dict) ``` [[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-lazyImports/docs/HuntingDog.md b/samples/openapi3/client/petstore/python-lazyImports/docs/HuntingDog.md index 6db6745dd022..114dfc8575d9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/HuntingDog.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/HuntingDog.md @@ -15,14 +15,14 @@ from petstore_api.models.hunting_dog import HuntingDog # TODO update the JSON string below json = "{}" # create an instance of HuntingDog from a JSON string -hunting_dog_instance = HuntingDog.from_json(json) +hunting_dog_instance = HuntingDog.model_validate_json(json) # print the JSON string representation of the object -print(HuntingDog.to_json()) +print(hunting_dog_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -hunting_dog_dict = hunting_dog_instance.to_dict() +hunting_dog_dict = hunting_dog_instance.model_dump(by_alias=True) # create an instance of HuntingDog from a dict -hunting_dog_from_dict = HuntingDog.from_dict(hunting_dog_dict) +hunting_dog_from_dict = HuntingDog.model_validate(hunting_dog_dict) ``` [[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-lazyImports/docs/Info.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Info.md index db88778a9143..160c3633247c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Info.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Info.md @@ -15,14 +15,14 @@ from petstore_api.models.info import Info # TODO update the JSON string below json = "{}" # create an instance of Info from a JSON string -info_instance = Info.from_json(json) +info_instance = Info.model_validate_json(json) # print the JSON string representation of the object -print(Info.to_json()) +print(info_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -info_dict = info_instance.to_dict() +info_dict = info_instance.model_dump(by_alias=True) # create an instance of Info from a dict -info_from_dict = Info.from_dict(info_dict) +info_from_dict = Info.model_validate(info_dict) ``` [[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-lazyImports/docs/InnerDictWithProperty.md b/samples/openapi3/client/petstore/python-lazyImports/docs/InnerDictWithProperty.md index 7b82ebb770b8..79234d754027 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/InnerDictWithProperty.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/InnerDictWithProperty.md @@ -15,14 +15,14 @@ from petstore_api.models.inner_dict_with_property import InnerDictWithProperty # TODO update the JSON string below json = "{}" # create an instance of InnerDictWithProperty from a JSON string -inner_dict_with_property_instance = InnerDictWithProperty.from_json(json) +inner_dict_with_property_instance = InnerDictWithProperty.model_validate_json(json) # print the JSON string representation of the object -print(InnerDictWithProperty.to_json()) +print(inner_dict_with_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -inner_dict_with_property_dict = inner_dict_with_property_instance.to_dict() +inner_dict_with_property_dict = inner_dict_with_property_instance.model_dump(by_alias=True) # create an instance of InnerDictWithProperty from a dict -inner_dict_with_property_from_dict = InnerDictWithProperty.from_dict(inner_dict_with_property_dict) +inner_dict_with_property_from_dict = InnerDictWithProperty.model_validate(inner_dict_with_property_dict) ``` [[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-lazyImports/docs/InputAllOf.md b/samples/openapi3/client/petstore/python-lazyImports/docs/InputAllOf.md index 45298f5308fc..32d4100ac9de 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/InputAllOf.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/InputAllOf.md @@ -15,14 +15,14 @@ from petstore_api.models.input_all_of import InputAllOf # TODO update the JSON string below json = "{}" # create an instance of InputAllOf from a JSON string -input_all_of_instance = InputAllOf.from_json(json) +input_all_of_instance = InputAllOf.model_validate_json(json) # print the JSON string representation of the object -print(InputAllOf.to_json()) +print(input_all_of_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -input_all_of_dict = input_all_of_instance.to_dict() +input_all_of_dict = input_all_of_instance.model_dump(by_alias=True) # create an instance of InputAllOf from a dict -input_all_of_from_dict = InputAllOf.from_dict(input_all_of_dict) +input_all_of_from_dict = InputAllOf.model_validate(input_all_of_dict) ``` [[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-lazyImports/docs/IntOrString.md b/samples/openapi3/client/petstore/python-lazyImports/docs/IntOrString.md index b4070b9a8c79..ea8e06339493 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/IntOrString.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/IntOrString.md @@ -14,14 +14,14 @@ from petstore_api.models.int_or_string import IntOrString # TODO update the JSON string below json = "{}" # create an instance of IntOrString from a JSON string -int_or_string_instance = IntOrString.from_json(json) +int_or_string_instance = IntOrString.model_validate_json(json) # print the JSON string representation of the object -print(IntOrString.to_json()) +print(int_or_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -int_or_string_dict = int_or_string_instance.to_dict() +int_or_string_dict = int_or_string_instance.model_dump(by_alias=True) # create an instance of IntOrString from a dict -int_or_string_from_dict = IntOrString.from_dict(int_or_string_dict) +int_or_string_from_dict = IntOrString.model_validate(int_or_string_dict) ``` [[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-lazyImports/docs/ListClass.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ListClass.md index 01068b7d22c3..8bc905105efe 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ListClass.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ListClass.md @@ -15,14 +15,14 @@ from petstore_api.models.list_class import ListClass # TODO update the JSON string below json = "{}" # create an instance of ListClass from a JSON string -list_class_instance = ListClass.from_json(json) +list_class_instance = ListClass.model_validate_json(json) # print the JSON string representation of the object -print(ListClass.to_json()) +print(list_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -list_class_dict = list_class_instance.to_dict() +list_class_dict = list_class_instance.model_dump(by_alias=True) # create an instance of ListClass from a dict -list_class_from_dict = ListClass.from_dict(list_class_dict) +list_class_from_dict = ListClass.model_validate(list_class_dict) ``` [[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-lazyImports/docs/MapOfArrayOfModel.md b/samples/openapi3/client/petstore/python-lazyImports/docs/MapOfArrayOfModel.md index 71a4ef66b682..acea13d9a9f5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/MapOfArrayOfModel.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/MapOfArrayOfModel.md @@ -15,14 +15,14 @@ from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel # TODO update the JSON string below json = "{}" # create an instance of MapOfArrayOfModel from a JSON string -map_of_array_of_model_instance = MapOfArrayOfModel.from_json(json) +map_of_array_of_model_instance = MapOfArrayOfModel.model_validate_json(json) # print the JSON string representation of the object -print(MapOfArrayOfModel.to_json()) +print(map_of_array_of_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -map_of_array_of_model_dict = map_of_array_of_model_instance.to_dict() +map_of_array_of_model_dict = map_of_array_of_model_instance.model_dump(by_alias=True) # create an instance of MapOfArrayOfModel from a dict -map_of_array_of_model_from_dict = MapOfArrayOfModel.from_dict(map_of_array_of_model_dict) +map_of_array_of_model_from_dict = MapOfArrayOfModel.model_validate(map_of_array_of_model_dict) ``` [[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-lazyImports/docs/MapTest.md b/samples/openapi3/client/petstore/python-lazyImports/docs/MapTest.md index d04b82e9378c..fa4501d24286 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/MapTest.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/MapTest.md @@ -18,14 +18,14 @@ from petstore_api.models.map_test import MapTest # TODO update the JSON string below json = "{}" # create an instance of MapTest from a JSON string -map_test_instance = MapTest.from_json(json) +map_test_instance = MapTest.model_validate_json(json) # print the JSON string representation of the object -print(MapTest.to_json()) +print(map_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -map_test_dict = map_test_instance.to_dict() +map_test_dict = map_test_instance.model_dump(by_alias=True) # create an instance of MapTest from a dict -map_test_from_dict = MapTest.from_dict(map_test_dict) +map_test_from_dict = MapTest.model_validate(map_test_dict) ``` [[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-lazyImports/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-lazyImports/docs/MixedPropertiesAndAdditionalPropertiesClass.md index 84134317aefc..fb354956720a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -17,14 +17,14 @@ from petstore_api.models.mixed_properties_and_additional_properties_class import # TODO update the JSON string below json = "{}" # create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string -mixed_properties_and_additional_properties_class_instance = MixedPropertiesAndAdditionalPropertiesClass.from_json(json) +mixed_properties_and_additional_properties_class_instance = MixedPropertiesAndAdditionalPropertiesClass.model_validate_json(json) # print the JSON string representation of the object -print(MixedPropertiesAndAdditionalPropertiesClass.to_json()) +print(mixed_properties_and_additional_properties_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -mixed_properties_and_additional_properties_class_dict = mixed_properties_and_additional_properties_class_instance.to_dict() +mixed_properties_and_additional_properties_class_dict = mixed_properties_and_additional_properties_class_instance.model_dump(by_alias=True) # create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict -mixed_properties_and_additional_properties_class_from_dict = MixedPropertiesAndAdditionalPropertiesClass.from_dict(mixed_properties_and_additional_properties_class_dict) +mixed_properties_and_additional_properties_class_from_dict = MixedPropertiesAndAdditionalPropertiesClass.model_validate(mixed_properties_and_additional_properties_class_dict) ``` [[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-lazyImports/docs/Model200Response.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Model200Response.md index 7fdbdefc6cec..6cffad7a6d3a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Model200Response.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Model200Response.md @@ -17,14 +17,14 @@ from petstore_api.models.model200_response import Model200Response # TODO update the JSON string below json = "{}" # create an instance of Model200Response from a JSON string -model200_response_instance = Model200Response.from_json(json) +model200_response_instance = Model200Response.model_validate_json(json) # print the JSON string representation of the object -print(Model200Response.to_json()) +print(model200_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model200_response_dict = model200_response_instance.to_dict() +model200_response_dict = model200_response_instance.model_dump(by_alias=True) # create an instance of Model200Response from a dict -model200_response_from_dict = Model200Response.from_dict(model200_response_dict) +model200_response_from_dict = Model200Response.model_validate(model200_response_dict) ``` [[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-lazyImports/docs/ModelApiResponse.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ModelApiResponse.md index 5ddc0db2a0f3..4fdaa910bce4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ModelApiResponse.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ModelApiResponse.md @@ -17,14 +17,14 @@ from petstore_api.models.model_api_response import ModelApiResponse # TODO update the JSON string below json = "{}" # create an instance of ModelApiResponse from a JSON string -model_api_response_instance = ModelApiResponse.from_json(json) +model_api_response_instance = ModelApiResponse.model_validate_json(json) # print the JSON string representation of the object -print(ModelApiResponse.to_json()) +print(model_api_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_api_response_dict = model_api_response_instance.to_dict() +model_api_response_dict = model_api_response_instance.model_dump(by_alias=True) # create an instance of ModelApiResponse from a dict -model_api_response_from_dict = ModelApiResponse.from_dict(model_api_response_dict) +model_api_response_from_dict = ModelApiResponse.model_validate(model_api_response_dict) ``` [[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-lazyImports/docs/ModelField.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ModelField.md index 9073b5dbdb00..43f064bd85a4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ModelField.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ModelField.md @@ -15,14 +15,14 @@ from petstore_api.models.model_field import ModelField # TODO update the JSON string below json = "{}" # create an instance of ModelField from a JSON string -model_field_instance = ModelField.from_json(json) +model_field_instance = ModelField.model_validate_json(json) # print the JSON string representation of the object -print(ModelField.to_json()) +print(model_field_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_field_dict = model_field_instance.to_dict() +model_field_dict = model_field_instance.model_dump(by_alias=True) # create an instance of ModelField from a dict -model_field_from_dict = ModelField.from_dict(model_field_dict) +model_field_from_dict = ModelField.model_validate(model_field_dict) ``` [[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-lazyImports/docs/ModelReturn.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ModelReturn.md index 7d327053b0c3..236b2bb971ee 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ModelReturn.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ModelReturn.md @@ -16,14 +16,14 @@ from petstore_api.models.model_return import ModelReturn # TODO update the JSON string below json = "{}" # create an instance of ModelReturn from a JSON string -model_return_instance = ModelReturn.from_json(json) +model_return_instance = ModelReturn.model_validate_json(json) # print the JSON string representation of the object -print(ModelReturn.to_json()) +print(model_return_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_return_dict = model_return_instance.to_dict() +model_return_dict = model_return_instance.model_dump(by_alias=True) # create an instance of ModelReturn from a dict -model_return_from_dict = ModelReturn.from_dict(model_return_dict) +model_return_from_dict = ModelReturn.model_validate(model_return_dict) ``` [[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-lazyImports/docs/MultiArrays.md b/samples/openapi3/client/petstore/python-lazyImports/docs/MultiArrays.md index fea5139e7e73..9cf5c5bb1faa 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/MultiArrays.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/MultiArrays.md @@ -16,14 +16,14 @@ from petstore_api.models.multi_arrays import MultiArrays # TODO update the JSON string below json = "{}" # create an instance of MultiArrays from a JSON string -multi_arrays_instance = MultiArrays.from_json(json) +multi_arrays_instance = MultiArrays.model_validate_json(json) # print the JSON string representation of the object -print(MultiArrays.to_json()) +print(multi_arrays_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -multi_arrays_dict = multi_arrays_instance.to_dict() +multi_arrays_dict = multi_arrays_instance.model_dump(by_alias=True) # create an instance of MultiArrays from a dict -multi_arrays_from_dict = MultiArrays.from_dict(multi_arrays_dict) +multi_arrays_from_dict = MultiArrays.model_validate(multi_arrays_dict) ``` [[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-lazyImports/docs/Name.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Name.md index 5a04ec1ada06..f9d2da4cccd2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Name.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Name.md @@ -19,14 +19,14 @@ from petstore_api.models.name import Name # TODO update the JSON string below json = "{}" # create an instance of Name from a JSON string -name_instance = Name.from_json(json) +name_instance = Name.model_validate_json(json) # print the JSON string representation of the object -print(Name.to_json()) +print(name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -name_dict = name_instance.to_dict() +name_dict = name_instance.model_dump(by_alias=True) # create an instance of Name from a dict -name_from_dict = Name.from_dict(name_dict) +name_from_dict = Name.model_validate(name_dict) ``` [[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-lazyImports/docs/NullableClass.md b/samples/openapi3/client/petstore/python-lazyImports/docs/NullableClass.md index 0387dcc2c67a..cd84aa96eb19 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/NullableClass.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/NullableClass.md @@ -27,14 +27,14 @@ from petstore_api.models.nullable_class import NullableClass # TODO update the JSON string below json = "{}" # create an instance of NullableClass from a JSON string -nullable_class_instance = NullableClass.from_json(json) +nullable_class_instance = NullableClass.model_validate_json(json) # print the JSON string representation of the object -print(NullableClass.to_json()) +print(nullable_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -nullable_class_dict = nullable_class_instance.to_dict() +nullable_class_dict = nullable_class_instance.model_dump(by_alias=True) # create an instance of NullableClass from a dict -nullable_class_from_dict = NullableClass.from_dict(nullable_class_dict) +nullable_class_from_dict = NullableClass.model_validate(nullable_class_dict) ``` [[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-lazyImports/docs/NullableProperty.md b/samples/openapi3/client/petstore/python-lazyImports/docs/NullableProperty.md index 30edaf4844b2..c0ef9b80fcb5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/NullableProperty.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/NullableProperty.md @@ -16,14 +16,14 @@ from petstore_api.models.nullable_property import NullableProperty # TODO update the JSON string below json = "{}" # create an instance of NullableProperty from a JSON string -nullable_property_instance = NullableProperty.from_json(json) +nullable_property_instance = NullableProperty.model_validate_json(json) # print the JSON string representation of the object -print(NullableProperty.to_json()) +print(nullable_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -nullable_property_dict = nullable_property_instance.to_dict() +nullable_property_dict = nullable_property_instance.model_dump(by_alias=True) # create an instance of NullableProperty from a dict -nullable_property_from_dict = NullableProperty.from_dict(nullable_property_dict) +nullable_property_from_dict = NullableProperty.model_validate(nullable_property_dict) ``` [[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-lazyImports/docs/NumberOnly.md b/samples/openapi3/client/petstore/python-lazyImports/docs/NumberOnly.md index 415dd25585d4..f1caf70ea2b7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/NumberOnly.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/NumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.number_only import NumberOnly # TODO update the JSON string below json = "{}" # create an instance of NumberOnly from a JSON string -number_only_instance = NumberOnly.from_json(json) +number_only_instance = NumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(NumberOnly.to_json()) +print(number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -number_only_dict = number_only_instance.to_dict() +number_only_dict = number_only_instance.model_dump(by_alias=True) # create an instance of NumberOnly from a dict -number_only_from_dict = NumberOnly.from_dict(number_only_dict) +number_only_from_dict = NumberOnly.model_validate(number_only_dict) ``` [[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-lazyImports/docs/ObjectToTestAdditionalProperties.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ObjectToTestAdditionalProperties.md index f6bc34c98e65..f201a9627dc3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ObjectToTestAdditionalProperties.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ObjectToTestAdditionalProperties.md @@ -16,14 +16,14 @@ from petstore_api.models.object_to_test_additional_properties import ObjectToTes # TODO update the JSON string below json = "{}" # create an instance of ObjectToTestAdditionalProperties from a JSON string -object_to_test_additional_properties_instance = ObjectToTestAdditionalProperties.from_json(json) +object_to_test_additional_properties_instance = ObjectToTestAdditionalProperties.model_validate_json(json) # print the JSON string representation of the object -print(ObjectToTestAdditionalProperties.to_json()) +print(object_to_test_additional_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -object_to_test_additional_properties_dict = object_to_test_additional_properties_instance.to_dict() +object_to_test_additional_properties_dict = object_to_test_additional_properties_instance.model_dump(by_alias=True) # create an instance of ObjectToTestAdditionalProperties from a dict -object_to_test_additional_properties_from_dict = ObjectToTestAdditionalProperties.from_dict(object_to_test_additional_properties_dict) +object_to_test_additional_properties_from_dict = ObjectToTestAdditionalProperties.model_validate(object_to_test_additional_properties_dict) ``` [[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-lazyImports/docs/ObjectWithDeprecatedFields.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ObjectWithDeprecatedFields.md index 6dbd2ace04f1..86cce93ba775 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ObjectWithDeprecatedFields.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ObjectWithDeprecatedFields.md @@ -18,14 +18,14 @@ from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecat # TODO update the JSON string below json = "{}" # create an instance of ObjectWithDeprecatedFields from a JSON string -object_with_deprecated_fields_instance = ObjectWithDeprecatedFields.from_json(json) +object_with_deprecated_fields_instance = ObjectWithDeprecatedFields.model_validate_json(json) # print the JSON string representation of the object -print(ObjectWithDeprecatedFields.to_json()) +print(object_with_deprecated_fields_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -object_with_deprecated_fields_dict = object_with_deprecated_fields_instance.to_dict() +object_with_deprecated_fields_dict = object_with_deprecated_fields_instance.model_dump(by_alias=True) # create an instance of ObjectWithDeprecatedFields from a dict -object_with_deprecated_fields_from_dict = ObjectWithDeprecatedFields.from_dict(object_with_deprecated_fields_dict) +object_with_deprecated_fields_from_dict = ObjectWithDeprecatedFields.model_validate(object_with_deprecated_fields_dict) ``` [[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-lazyImports/docs/OneOfEnumString.md b/samples/openapi3/client/petstore/python-lazyImports/docs/OneOfEnumString.md index 1d385c092934..69f4f99d32e4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/OneOfEnumString.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/OneOfEnumString.md @@ -15,14 +15,14 @@ from petstore_api.models.one_of_enum_string import OneOfEnumString # TODO update the JSON string below json = "{}" # create an instance of OneOfEnumString from a JSON string -one_of_enum_string_instance = OneOfEnumString.from_json(json) +one_of_enum_string_instance = OneOfEnumString.model_validate_json(json) # print the JSON string representation of the object -print(OneOfEnumString.to_json()) +print(one_of_enum_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -one_of_enum_string_dict = one_of_enum_string_instance.to_dict() +one_of_enum_string_dict = one_of_enum_string_instance.model_dump(by_alias=True) # create an instance of OneOfEnumString from a dict -one_of_enum_string_from_dict = OneOfEnumString.from_dict(one_of_enum_string_dict) +one_of_enum_string_from_dict = OneOfEnumString.model_validate(one_of_enum_string_dict) ``` [[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-lazyImports/docs/Order.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Order.md index 00526b8d04b9..f5410bc8d0f3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Order.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Order.md @@ -20,14 +20,14 @@ from petstore_api.models.order import Order # TODO update the JSON string below json = "{}" # create an instance of Order from a JSON string -order_instance = Order.from_json(json) +order_instance = Order.model_validate_json(json) # print the JSON string representation of the object -print(Order.to_json()) +print(order_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -order_dict = order_instance.to_dict() +order_dict = order_instance.model_dump(by_alias=True) # create an instance of Order from a dict -order_from_dict = Order.from_dict(order_dict) +order_from_dict = Order.model_validate(order_dict) ``` [[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-lazyImports/docs/OuterComposite.md b/samples/openapi3/client/petstore/python-lazyImports/docs/OuterComposite.md index c8242c2d2653..9df82e2abc87 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/OuterComposite.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/OuterComposite.md @@ -17,14 +17,14 @@ from petstore_api.models.outer_composite import OuterComposite # TODO update the JSON string below json = "{}" # create an instance of OuterComposite from a JSON string -outer_composite_instance = OuterComposite.from_json(json) +outer_composite_instance = OuterComposite.model_validate_json(json) # print the JSON string representation of the object -print(OuterComposite.to_json()) +print(outer_composite_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -outer_composite_dict = outer_composite_instance.to_dict() +outer_composite_dict = outer_composite_instance.model_dump(by_alias=True) # create an instance of OuterComposite from a dict -outer_composite_from_dict = OuterComposite.from_dict(outer_composite_dict) +outer_composite_from_dict = OuterComposite.model_validate(outer_composite_dict) ``` [[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-lazyImports/docs/OuterObjectWithEnumProperty.md b/samples/openapi3/client/petstore/python-lazyImports/docs/OuterObjectWithEnumProperty.md index 6137dbd98da6..d23ccc3757bb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/OuterObjectWithEnumProperty.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/OuterObjectWithEnumProperty.md @@ -16,14 +16,14 @@ from petstore_api.models.outer_object_with_enum_property import OuterObjectWithE # TODO update the JSON string below json = "{}" # create an instance of OuterObjectWithEnumProperty from a JSON string -outer_object_with_enum_property_instance = OuterObjectWithEnumProperty.from_json(json) +outer_object_with_enum_property_instance = OuterObjectWithEnumProperty.model_validate_json(json) # print the JSON string representation of the object -print(OuterObjectWithEnumProperty.to_json()) +print(outer_object_with_enum_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -outer_object_with_enum_property_dict = outer_object_with_enum_property_instance.to_dict() +outer_object_with_enum_property_dict = outer_object_with_enum_property_instance.model_dump(by_alias=True) # create an instance of OuterObjectWithEnumProperty from a dict -outer_object_with_enum_property_from_dict = OuterObjectWithEnumProperty.from_dict(outer_object_with_enum_property_dict) +outer_object_with_enum_property_from_dict = OuterObjectWithEnumProperty.model_validate(outer_object_with_enum_property_dict) ``` [[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-lazyImports/docs/Parent.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Parent.md index 7387f9250aad..21df089ea756 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Parent.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Parent.md @@ -15,14 +15,14 @@ from petstore_api.models.parent import Parent # TODO update the JSON string below json = "{}" # create an instance of Parent from a JSON string -parent_instance = Parent.from_json(json) +parent_instance = Parent.model_validate_json(json) # print the JSON string representation of the object -print(Parent.to_json()) +print(parent_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -parent_dict = parent_instance.to_dict() +parent_dict = parent_instance.model_dump(by_alias=True) # create an instance of Parent from a dict -parent_from_dict = Parent.from_dict(parent_dict) +parent_from_dict = Parent.model_validate(parent_dict) ``` [[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-lazyImports/docs/ParentWithOptionalDict.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ParentWithOptionalDict.md index bfc8688ea26f..a6ee19fd1a74 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ParentWithOptionalDict.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ParentWithOptionalDict.md @@ -15,14 +15,14 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict # TODO update the JSON string below json = "{}" # create an instance of ParentWithOptionalDict from a JSON string -parent_with_optional_dict_instance = ParentWithOptionalDict.from_json(json) +parent_with_optional_dict_instance = ParentWithOptionalDict.model_validate_json(json) # print the JSON string representation of the object -print(ParentWithOptionalDict.to_json()) +print(parent_with_optional_dict_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -parent_with_optional_dict_dict = parent_with_optional_dict_instance.to_dict() +parent_with_optional_dict_dict = parent_with_optional_dict_instance.model_dump(by_alias=True) # create an instance of ParentWithOptionalDict from a dict -parent_with_optional_dict_from_dict = ParentWithOptionalDict.from_dict(parent_with_optional_dict_dict) +parent_with_optional_dict_from_dict = ParentWithOptionalDict.model_validate(parent_with_optional_dict_dict) ``` [[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-lazyImports/docs/Pet.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Pet.md index 5329cf2fb925..179b71891d9d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Pet.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Pet.md @@ -20,14 +20,14 @@ from petstore_api.models.pet import Pet # TODO update the JSON string below json = "{}" # create an instance of Pet from a JSON string -pet_instance = Pet.from_json(json) +pet_instance = Pet.model_validate_json(json) # print the JSON string representation of the object -print(Pet.to_json()) +print(pet_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pet_dict = pet_instance.to_dict() +pet_dict = pet_instance.model_dump(by_alias=True) # create an instance of Pet from a dict -pet_from_dict = Pet.from_dict(pet_dict) +pet_from_dict = Pet.model_validate(pet_dict) ``` [[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-lazyImports/docs/Pig.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Pig.md index 625930676083..2e275198c547 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Pig.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Pig.md @@ -17,14 +17,14 @@ from petstore_api.models.pig import Pig # TODO update the JSON string below json = "{}" # create an instance of Pig from a JSON string -pig_instance = Pig.from_json(json) +pig_instance = Pig.model_validate_json(json) # print the JSON string representation of the object -print(Pig.to_json()) +print(pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pig_dict = pig_instance.to_dict() +pig_dict = pig_instance.model_dump(by_alias=True) # create an instance of Pig from a dict -pig_from_dict = Pig.from_dict(pig_dict) +pig_from_dict = Pig.model_validate(pig_dict) ``` [[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-lazyImports/docs/PonySizes.md b/samples/openapi3/client/petstore/python-lazyImports/docs/PonySizes.md index ced44c872060..6bb28b418b6d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/PonySizes.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/PonySizes.md @@ -15,14 +15,14 @@ from petstore_api.models.pony_sizes import PonySizes # TODO update the JSON string below json = "{}" # create an instance of PonySizes from a JSON string -pony_sizes_instance = PonySizes.from_json(json) +pony_sizes_instance = PonySizes.model_validate_json(json) # print the JSON string representation of the object -print(PonySizes.to_json()) +print(pony_sizes_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pony_sizes_dict = pony_sizes_instance.to_dict() +pony_sizes_dict = pony_sizes_instance.model_dump(by_alias=True) # create an instance of PonySizes from a dict -pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_dict) +pony_sizes_from_dict = PonySizes.model_validate(pony_sizes_dict) ``` [[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-lazyImports/docs/PoopCleaning.md b/samples/openapi3/client/petstore/python-lazyImports/docs/PoopCleaning.md index 8f9c25e08316..3bf20593f929 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/PoopCleaning.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/PoopCleaning.md @@ -17,14 +17,14 @@ from petstore_api.models.poop_cleaning import PoopCleaning # TODO update the JSON string below json = "{}" # create an instance of PoopCleaning from a JSON string -poop_cleaning_instance = PoopCleaning.from_json(json) +poop_cleaning_instance = PoopCleaning.model_validate_json(json) # print the JSON string representation of the object -print(PoopCleaning.to_json()) +print(poop_cleaning_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -poop_cleaning_dict = poop_cleaning_instance.to_dict() +poop_cleaning_dict = poop_cleaning_instance.model_dump(by_alias=True) # create an instance of PoopCleaning from a dict -poop_cleaning_from_dict = PoopCleaning.from_dict(poop_cleaning_dict) +poop_cleaning_from_dict = PoopCleaning.model_validate(poop_cleaning_dict) ``` [[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-lazyImports/docs/PrimitiveString.md b/samples/openapi3/client/petstore/python-lazyImports/docs/PrimitiveString.md index 85ceb632e167..a1a9a3dc81b6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/PrimitiveString.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/PrimitiveString.md @@ -15,14 +15,14 @@ from petstore_api.models.primitive_string import PrimitiveString # TODO update the JSON string below json = "{}" # create an instance of PrimitiveString from a JSON string -primitive_string_instance = PrimitiveString.from_json(json) +primitive_string_instance = PrimitiveString.model_validate_json(json) # print the JSON string representation of the object -print(PrimitiveString.to_json()) +print(primitive_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -primitive_string_dict = primitive_string_instance.to_dict() +primitive_string_dict = primitive_string_instance.model_dump(by_alias=True) # create an instance of PrimitiveString from a dict -primitive_string_from_dict = PrimitiveString.from_dict(primitive_string_dict) +primitive_string_from_dict = PrimitiveString.model_validate(primitive_string_dict) ``` [[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-lazyImports/docs/PropertyMap.md b/samples/openapi3/client/petstore/python-lazyImports/docs/PropertyMap.md index a55a0e5c6f01..5fcda1f7803d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/PropertyMap.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/PropertyMap.md @@ -15,14 +15,14 @@ from petstore_api.models.property_map import PropertyMap # TODO update the JSON string below json = "{}" # create an instance of PropertyMap from a JSON string -property_map_instance = PropertyMap.from_json(json) +property_map_instance = PropertyMap.model_validate_json(json) # print the JSON string representation of the object -print(PropertyMap.to_json()) +print(property_map_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -property_map_dict = property_map_instance.to_dict() +property_map_dict = property_map_instance.model_dump(by_alias=True) # create an instance of PropertyMap from a dict -property_map_from_dict = PropertyMap.from_dict(property_map_dict) +property_map_from_dict = PropertyMap.model_validate(property_map_dict) ``` [[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-lazyImports/docs/PropertyNameCollision.md b/samples/openapi3/client/petstore/python-lazyImports/docs/PropertyNameCollision.md index 40c233670dd0..a4a8405fe847 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/PropertyNameCollision.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/PropertyNameCollision.md @@ -17,14 +17,14 @@ from petstore_api.models.property_name_collision import PropertyNameCollision # TODO update the JSON string below json = "{}" # create an instance of PropertyNameCollision from a JSON string -property_name_collision_instance = PropertyNameCollision.from_json(json) +property_name_collision_instance = PropertyNameCollision.model_validate_json(json) # print the JSON string representation of the object -print(PropertyNameCollision.to_json()) +print(property_name_collision_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -property_name_collision_dict = property_name_collision_instance.to_dict() +property_name_collision_dict = property_name_collision_instance.model_dump(by_alias=True) # create an instance of PropertyNameCollision from a dict -property_name_collision_from_dict = PropertyNameCollision.from_dict(property_name_collision_dict) +property_name_collision_from_dict = PropertyNameCollision.model_validate(property_name_collision_dict) ``` [[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-lazyImports/docs/ReadOnlyFirst.md b/samples/openapi3/client/petstore/python-lazyImports/docs/ReadOnlyFirst.md index 686ec5da41c9..e55fe102b673 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/ReadOnlyFirst.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/ReadOnlyFirst.md @@ -16,14 +16,14 @@ from petstore_api.models.read_only_first import ReadOnlyFirst # TODO update the JSON string below json = "{}" # create an instance of ReadOnlyFirst from a JSON string -read_only_first_instance = ReadOnlyFirst.from_json(json) +read_only_first_instance = ReadOnlyFirst.model_validate_json(json) # print the JSON string representation of the object -print(ReadOnlyFirst.to_json()) +print(read_only_first_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -read_only_first_dict = read_only_first_instance.to_dict() +read_only_first_dict = read_only_first_instance.model_dump(by_alias=True) # create an instance of ReadOnlyFirst from a dict -read_only_first_from_dict = ReadOnlyFirst.from_dict(read_only_first_dict) +read_only_first_from_dict = ReadOnlyFirst.model_validate(read_only_first_dict) ``` [[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-lazyImports/docs/SecondCircularAllOfRef.md b/samples/openapi3/client/petstore/python-lazyImports/docs/SecondCircularAllOfRef.md index 65ebdd4c7e1d..47fb4daf97a4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/SecondCircularAllOfRef.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/SecondCircularAllOfRef.md @@ -16,14 +16,14 @@ from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRe # TODO update the JSON string below json = "{}" # create an instance of SecondCircularAllOfRef from a JSON string -second_circular_all_of_ref_instance = SecondCircularAllOfRef.from_json(json) +second_circular_all_of_ref_instance = SecondCircularAllOfRef.model_validate_json(json) # print the JSON string representation of the object -print(SecondCircularAllOfRef.to_json()) +print(second_circular_all_of_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -second_circular_all_of_ref_dict = second_circular_all_of_ref_instance.to_dict() +second_circular_all_of_ref_dict = second_circular_all_of_ref_instance.model_dump(by_alias=True) # create an instance of SecondCircularAllOfRef from a dict -second_circular_all_of_ref_from_dict = SecondCircularAllOfRef.from_dict(second_circular_all_of_ref_dict) +second_circular_all_of_ref_from_dict = SecondCircularAllOfRef.model_validate(second_circular_all_of_ref_dict) ``` [[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-lazyImports/docs/SecondRef.md b/samples/openapi3/client/petstore/python-lazyImports/docs/SecondRef.md index dfb1a0ac6db5..fa0b9f285e0c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/SecondRef.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/SecondRef.md @@ -16,14 +16,14 @@ from petstore_api.models.second_ref import SecondRef # TODO update the JSON string below json = "{}" # create an instance of SecondRef from a JSON string -second_ref_instance = SecondRef.from_json(json) +second_ref_instance = SecondRef.model_validate_json(json) # print the JSON string representation of the object -print(SecondRef.to_json()) +print(second_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -second_ref_dict = second_ref_instance.to_dict() +second_ref_dict = second_ref_instance.model_dump(by_alias=True) # create an instance of SecondRef from a dict -second_ref_from_dict = SecondRef.from_dict(second_ref_dict) +second_ref_from_dict = SecondRef.model_validate(second_ref_dict) ``` [[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-lazyImports/docs/SelfReferenceModel.md b/samples/openapi3/client/petstore/python-lazyImports/docs/SelfReferenceModel.md index 208cdac04b6f..af3c77d0524b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/SelfReferenceModel.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/SelfReferenceModel.md @@ -16,14 +16,14 @@ from petstore_api.models.self_reference_model import SelfReferenceModel # TODO update the JSON string below json = "{}" # create an instance of SelfReferenceModel from a JSON string -self_reference_model_instance = SelfReferenceModel.from_json(json) +self_reference_model_instance = SelfReferenceModel.model_validate_json(json) # print the JSON string representation of the object -print(SelfReferenceModel.to_json()) +print(self_reference_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -self_reference_model_dict = self_reference_model_instance.to_dict() +self_reference_model_dict = self_reference_model_instance.model_dump(by_alias=True) # create an instance of SelfReferenceModel from a dict -self_reference_model_from_dict = SelfReferenceModel.from_dict(self_reference_model_dict) +self_reference_model_from_dict = SelfReferenceModel.model_validate(self_reference_model_dict) ``` [[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-lazyImports/docs/SpecialModelName.md b/samples/openapi3/client/petstore/python-lazyImports/docs/SpecialModelName.md index 35303f34efd2..589dbeb14b94 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/SpecialModelName.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/SpecialModelName.md @@ -15,14 +15,14 @@ from petstore_api.models.special_model_name import SpecialModelName # TODO update the JSON string below json = "{}" # create an instance of SpecialModelName from a JSON string -special_model_name_instance = SpecialModelName.from_json(json) +special_model_name_instance = SpecialModelName.model_validate_json(json) # print the JSON string representation of the object -print(SpecialModelName.to_json()) +print(special_model_name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -special_model_name_dict = special_model_name_instance.to_dict() +special_model_name_dict = special_model_name_instance.model_dump(by_alias=True) # create an instance of SpecialModelName from a dict -special_model_name_from_dict = SpecialModelName.from_dict(special_model_name_dict) +special_model_name_from_dict = SpecialModelName.model_validate(special_model_name_dict) ``` [[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-lazyImports/docs/SpecialName.md b/samples/openapi3/client/petstore/python-lazyImports/docs/SpecialName.md index ccc550b16e33..19da9016451c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/SpecialName.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/SpecialName.md @@ -17,14 +17,14 @@ from petstore_api.models.special_name import SpecialName # TODO update the JSON string below json = "{}" # create an instance of SpecialName from a JSON string -special_name_instance = SpecialName.from_json(json) +special_name_instance = SpecialName.model_validate_json(json) # print the JSON string representation of the object -print(SpecialName.to_json()) +print(special_name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -special_name_dict = special_name_instance.to_dict() +special_name_dict = special_name_instance.model_dump(by_alias=True) # create an instance of SpecialName from a dict -special_name_from_dict = SpecialName.from_dict(special_name_dict) +special_name_from_dict = SpecialName.model_validate(special_name_dict) ``` [[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-lazyImports/docs/Tag.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Tag.md index 4106d9cfe5db..66339d14c875 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Tag.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Tag.md @@ -16,14 +16,14 @@ from petstore_api.models.tag import Tag # TODO update the JSON string below json = "{}" # create an instance of Tag from a JSON string -tag_instance = Tag.from_json(json) +tag_instance = Tag.model_validate_json(json) # print the JSON string representation of the object -print(Tag.to_json()) +print(tag_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tag_dict = tag_instance.to_dict() +tag_dict = tag_instance.model_dump(by_alias=True) # create an instance of Tag from a dict -tag_from_dict = Tag.from_dict(tag_dict) +tag_from_dict = Tag.model_validate(tag_dict) ``` [[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-lazyImports/docs/Task.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Task.md index 85fa2776a059..229ed6510a11 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Task.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Task.md @@ -17,14 +17,14 @@ from petstore_api.models.task import Task # TODO update the JSON string below json = "{}" # create an instance of Task from a JSON string -task_instance = Task.from_json(json) +task_instance = Task.model_validate_json(json) # print the JSON string representation of the object -print(Task.to_json()) +print(task_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -task_dict = task_instance.to_dict() +task_dict = task_instance.model_dump(by_alias=True) # create an instance of Task from a dict -task_from_dict = Task.from_dict(task_dict) +task_from_dict = Task.model_validate(task_dict) ``` [[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-lazyImports/docs/TaskActivity.md b/samples/openapi3/client/petstore/python-lazyImports/docs/TaskActivity.md index e905a477292d..c025d32ba436 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/TaskActivity.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/TaskActivity.md @@ -17,14 +17,14 @@ from petstore_api.models.task_activity import TaskActivity # TODO update the JSON string below json = "{}" # create an instance of TaskActivity from a JSON string -task_activity_instance = TaskActivity.from_json(json) +task_activity_instance = TaskActivity.model_validate_json(json) # print the JSON string representation of the object -print(TaskActivity.to_json()) +print(task_activity_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -task_activity_dict = task_activity_instance.to_dict() +task_activity_dict = task_activity_instance.model_dump(by_alias=True) # create an instance of TaskActivity from a dict -task_activity_from_dict = TaskActivity.from_dict(task_activity_dict) +task_activity_from_dict = TaskActivity.model_validate(task_activity_dict) ``` [[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-lazyImports/docs/TestErrorResponsesWithModel400Response.md b/samples/openapi3/client/petstore/python-lazyImports/docs/TestErrorResponsesWithModel400Response.md index be416bbad0f7..fed06705b55b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/TestErrorResponsesWithModel400Response.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/TestErrorResponsesWithModel400Response.md @@ -15,14 +15,14 @@ from petstore_api.models.test_error_responses_with_model400_response import Test # TODO update the JSON string below json = "{}" # create an instance of TestErrorResponsesWithModel400Response from a JSON string -test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.from_json(json) +test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.model_validate_json(json) # print the JSON string representation of the object -print(TestErrorResponsesWithModel400Response.to_json()) +print(test_error_responses_with_model400_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.to_dict() +test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.model_dump(by_alias=True) # create an instance of TestErrorResponsesWithModel400Response from a dict -test_error_responses_with_model400_response_from_dict = TestErrorResponsesWithModel400Response.from_dict(test_error_responses_with_model400_response_dict) +test_error_responses_with_model400_response_from_dict = TestErrorResponsesWithModel400Response.model_validate(test_error_responses_with_model400_response_dict) ``` [[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-lazyImports/docs/TestErrorResponsesWithModel404Response.md b/samples/openapi3/client/petstore/python-lazyImports/docs/TestErrorResponsesWithModel404Response.md index 1c984f847bf1..8813e0792d22 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/TestErrorResponsesWithModel404Response.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/TestErrorResponsesWithModel404Response.md @@ -15,14 +15,14 @@ from petstore_api.models.test_error_responses_with_model404_response import Test # TODO update the JSON string below json = "{}" # create an instance of TestErrorResponsesWithModel404Response from a JSON string -test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.from_json(json) +test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.model_validate_json(json) # print the JSON string representation of the object -print(TestErrorResponsesWithModel404Response.to_json()) +print(test_error_responses_with_model404_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.to_dict() +test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.model_dump(by_alias=True) # create an instance of TestErrorResponsesWithModel404Response from a dict -test_error_responses_with_model404_response_from_dict = TestErrorResponsesWithModel404Response.from_dict(test_error_responses_with_model404_response_dict) +test_error_responses_with_model404_response_from_dict = TestErrorResponsesWithModel404Response.model_validate(test_error_responses_with_model404_response_dict) ``` [[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-lazyImports/docs/TestInlineFreeformAdditionalPropertiesRequest.md b/samples/openapi3/client/petstore/python-lazyImports/docs/TestInlineFreeformAdditionalPropertiesRequest.md index 511132d689be..870cd8850e6b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/TestInlineFreeformAdditionalPropertiesRequest.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/TestInlineFreeformAdditionalPropertiesRequest.md @@ -15,14 +15,14 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo # TODO update the JSON string below json = "{}" # create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string -test_inline_freeform_additional_properties_request_instance = TestInlineFreeformAdditionalPropertiesRequest.from_json(json) +test_inline_freeform_additional_properties_request_instance = TestInlineFreeformAdditionalPropertiesRequest.model_validate_json(json) # print the JSON string representation of the object -print(TestInlineFreeformAdditionalPropertiesRequest.to_json()) +print(test_inline_freeform_additional_properties_request_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_inline_freeform_additional_properties_request_dict = test_inline_freeform_additional_properties_request_instance.to_dict() +test_inline_freeform_additional_properties_request_dict = test_inline_freeform_additional_properties_request_instance.model_dump(by_alias=True) # create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict -test_inline_freeform_additional_properties_request_from_dict = TestInlineFreeformAdditionalPropertiesRequest.from_dict(test_inline_freeform_additional_properties_request_dict) +test_inline_freeform_additional_properties_request_from_dict = TestInlineFreeformAdditionalPropertiesRequest.model_validate(test_inline_freeform_additional_properties_request_dict) ``` [[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-lazyImports/docs/TestModelWithEnumDefault.md b/samples/openapi3/client/petstore/python-lazyImports/docs/TestModelWithEnumDefault.md index 7d46e86deba4..1f63056fe0f1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/TestModelWithEnumDefault.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/TestModelWithEnumDefault.md @@ -19,14 +19,14 @@ from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDe # TODO update the JSON string below json = "{}" # create an instance of TestModelWithEnumDefault from a JSON string -test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json) +test_model_with_enum_default_instance = TestModelWithEnumDefault.model_validate_json(json) # print the JSON string representation of the object -print(TestModelWithEnumDefault.to_json()) +print(test_model_with_enum_default_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict() +test_model_with_enum_default_dict = test_model_with_enum_default_instance.model_dump(by_alias=True) # create an instance of TestModelWithEnumDefault from a dict -test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict) +test_model_with_enum_default_from_dict = TestModelWithEnumDefault.model_validate(test_model_with_enum_default_dict) ``` [[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-lazyImports/docs/TestObjectForMultipartRequestsRequestMarker.md b/samples/openapi3/client/petstore/python-lazyImports/docs/TestObjectForMultipartRequestsRequestMarker.md index ff0ca9ee00ac..bb685d44835a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/TestObjectForMultipartRequestsRequestMarker.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/TestObjectForMultipartRequestsRequestMarker.md @@ -15,14 +15,14 @@ from petstore_api.models.test_object_for_multipart_requests_request_marker impor # TODO update the JSON string below json = "{}" # create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string -test_object_for_multipart_requests_request_marker_instance = TestObjectForMultipartRequestsRequestMarker.from_json(json) +test_object_for_multipart_requests_request_marker_instance = TestObjectForMultipartRequestsRequestMarker.model_validate_json(json) # print the JSON string representation of the object -print(TestObjectForMultipartRequestsRequestMarker.to_json()) +print(test_object_for_multipart_requests_request_marker_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_object_for_multipart_requests_request_marker_dict = test_object_for_multipart_requests_request_marker_instance.to_dict() +test_object_for_multipart_requests_request_marker_dict = test_object_for_multipart_requests_request_marker_instance.model_dump(by_alias=True) # create an instance of TestObjectForMultipartRequestsRequestMarker from a dict -test_object_for_multipart_requests_request_marker_from_dict = TestObjectForMultipartRequestsRequestMarker.from_dict(test_object_for_multipart_requests_request_marker_dict) +test_object_for_multipart_requests_request_marker_from_dict = TestObjectForMultipartRequestsRequestMarker.model_validate(test_object_for_multipart_requests_request_marker_dict) ``` [[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-lazyImports/docs/Tiger.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Tiger.md index f1cf2133f0f7..90c7d8770979 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/Tiger.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Tiger.md @@ -15,14 +15,14 @@ from petstore_api.models.tiger import Tiger # TODO update the JSON string below json = "{}" # create an instance of Tiger from a JSON string -tiger_instance = Tiger.from_json(json) +tiger_instance = Tiger.model_validate_json(json) # print the JSON string representation of the object -print(Tiger.to_json()) +print(tiger_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tiger_dict = tiger_instance.to_dict() +tiger_dict = tiger_instance.model_dump(by_alias=True) # create an instance of Tiger from a dict -tiger_from_dict = Tiger.from_dict(tiger_dict) +tiger_from_dict = Tiger.model_validate(tiger_dict) ``` [[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-lazyImports/docs/UnnamedDictWithAdditionalModelListProperties.md b/samples/openapi3/client/petstore/python-lazyImports/docs/UnnamedDictWithAdditionalModelListProperties.md index 68cd00ab0a7a..0b411bf5df7b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/UnnamedDictWithAdditionalModelListProperties.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/UnnamedDictWithAdditionalModelListProperties.md @@ -15,14 +15,14 @@ from petstore_api.models.unnamed_dict_with_additional_model_list_properties impo # TODO update the JSON string below json = "{}" # create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string -unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.from_json(json) +unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.model_validate_json(json) # print the JSON string representation of the object -print(UnnamedDictWithAdditionalModelListProperties.to_json()) +print(unnamed_dict_with_additional_model_list_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.to_dict() +unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.model_dump(by_alias=True) # create an instance of UnnamedDictWithAdditionalModelListProperties from a dict -unnamed_dict_with_additional_model_list_properties_from_dict = UnnamedDictWithAdditionalModelListProperties.from_dict(unnamed_dict_with_additional_model_list_properties_dict) +unnamed_dict_with_additional_model_list_properties_from_dict = UnnamedDictWithAdditionalModelListProperties.model_validate(unnamed_dict_with_additional_model_list_properties_dict) ``` [[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-lazyImports/docs/UnnamedDictWithAdditionalStringListProperties.md b/samples/openapi3/client/petstore/python-lazyImports/docs/UnnamedDictWithAdditionalStringListProperties.md index 045b0e22ad09..def639720586 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/UnnamedDictWithAdditionalStringListProperties.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/UnnamedDictWithAdditionalStringListProperties.md @@ -15,14 +15,14 @@ from petstore_api.models.unnamed_dict_with_additional_string_list_properties imp # TODO update the JSON string below json = "{}" # create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string -unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.from_json(json) +unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.model_validate_json(json) # print the JSON string representation of the object -print(UnnamedDictWithAdditionalStringListProperties.to_json()) +print(unnamed_dict_with_additional_string_list_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.to_dict() +unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.model_dump(by_alias=True) # create an instance of UnnamedDictWithAdditionalStringListProperties from a dict -unnamed_dict_with_additional_string_list_properties_from_dict = UnnamedDictWithAdditionalStringListProperties.from_dict(unnamed_dict_with_additional_string_list_properties_dict) +unnamed_dict_with_additional_string_list_properties_from_dict = UnnamedDictWithAdditionalStringListProperties.model_validate(unnamed_dict_with_additional_string_list_properties_dict) ``` [[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-lazyImports/docs/UploadFileWithAdditionalPropertiesRequestObject.md b/samples/openapi3/client/petstore/python-lazyImports/docs/UploadFileWithAdditionalPropertiesRequestObject.md index 141027780371..35be1642e660 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/UploadFileWithAdditionalPropertiesRequestObject.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/UploadFileWithAdditionalPropertiesRequestObject.md @@ -16,14 +16,14 @@ from petstore_api.models.upload_file_with_additional_properties_request_object i # TODO update the JSON string below json = "{}" # create an instance of UploadFileWithAdditionalPropertiesRequestObject from a JSON string -upload_file_with_additional_properties_request_object_instance = UploadFileWithAdditionalPropertiesRequestObject.from_json(json) +upload_file_with_additional_properties_request_object_instance = UploadFileWithAdditionalPropertiesRequestObject.model_validate_json(json) # print the JSON string representation of the object -print(UploadFileWithAdditionalPropertiesRequestObject.to_json()) +print(upload_file_with_additional_properties_request_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -upload_file_with_additional_properties_request_object_dict = upload_file_with_additional_properties_request_object_instance.to_dict() +upload_file_with_additional_properties_request_object_dict = upload_file_with_additional_properties_request_object_instance.model_dump(by_alias=True) # create an instance of UploadFileWithAdditionalPropertiesRequestObject from a dict -upload_file_with_additional_properties_request_object_from_dict = UploadFileWithAdditionalPropertiesRequestObject.from_dict(upload_file_with_additional_properties_request_object_dict) +upload_file_with_additional_properties_request_object_from_dict = UploadFileWithAdditionalPropertiesRequestObject.model_validate(upload_file_with_additional_properties_request_object_dict) ``` [[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-lazyImports/docs/User.md b/samples/openapi3/client/petstore/python-lazyImports/docs/User.md index c45d26d27043..8f4ae3d04712 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/User.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/User.md @@ -22,14 +22,14 @@ from petstore_api.models.user import User # TODO update the JSON string below json = "{}" # create an instance of User from a JSON string -user_instance = User.from_json(json) +user_instance = User.model_validate_json(json) # print the JSON string representation of the object -print(User.to_json()) +print(user_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -user_dict = user_instance.to_dict() +user_dict = user_instance.model_dump(by_alias=True) # create an instance of User from a dict -user_from_dict = User.from_dict(user_dict) +user_from_dict = User.model_validate(user_dict) ``` [[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-lazyImports/docs/WithNestedOneOf.md b/samples/openapi3/client/petstore/python-lazyImports/docs/WithNestedOneOf.md index e7bbbc28fc2d..12d648bb920d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/WithNestedOneOf.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/WithNestedOneOf.md @@ -17,14 +17,14 @@ from petstore_api.models.with_nested_one_of import WithNestedOneOf # TODO update the JSON string below json = "{}" # create an instance of WithNestedOneOf from a JSON string -with_nested_one_of_instance = WithNestedOneOf.from_json(json) +with_nested_one_of_instance = WithNestedOneOf.model_validate_json(json) # print the JSON string representation of the object -print(WithNestedOneOf.to_json()) +print(with_nested_one_of_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -with_nested_one_of_dict = with_nested_one_of_instance.to_dict() +with_nested_one_of_dict = with_nested_one_of_instance.model_dump(by_alias=True) # create an instance of WithNestedOneOf from a dict -with_nested_one_of_from_dict = WithNestedOneOf.from_dict(with_nested_one_of_dict) +with_nested_one_of_from_dict = WithNestedOneOf.model_validate(with_nested_one_of_dict) ``` [[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-lazyImports/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py index 291b5e55e353..9c810c176590 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesAnyType(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesAnyType(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesAnyType from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesAnyType from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py index 220f23a423b4..a17e1f1dcb36 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesClass(BaseModel): """ @@ -38,65 +39,27 @@ class AdditionalPropertiesClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py index 00707c3c4818..75df3dc97cf4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesObject(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py index d8049b519ed0..a3dea0ab8ee6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesWithDescriptionOnly(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py index b63bba1206a2..bcab36b1dbec 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AllOfSuperModel(BaseModel): """ @@ -37,64 +38,27 @@ class AllOfSuperModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AllOfSuperModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AllOfSuperModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py index e3fa084b0709..7fad1a2d3b87 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.single_ref_type import SingleRefType from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AllOfWithSingleRef(BaseModel): """ @@ -39,65 +40,27 @@ class AllOfWithSingleRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AllOfWithSingleRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AllOfWithSingleRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "username": obj.get("username"), - "SingleRefType": obj.get("SingleRefType") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py index 131ad8d0ed60..5826bb1f15f1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -61,59 +62,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[Cat, Dog]]: - """Create an instance of Animal from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[Cat, Dog]]: - """Create an instance of Animal from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'Cat': - return import_module("petstore_api.models.cat").Cat.from_dict(obj) - if object_type == 'Dog': - return import_module("petstore_api.models.dog").Dog.from_dict(obj) - - raise ValueError("Animal failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py index f6d277e79498..b86b03be3591 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py @@ -13,8 +13,6 @@ from __future__ import annotations -from inspect import getfullargspec -import json import pprint import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator @@ -22,135 +20,56 @@ from typing_extensions import Annotated from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field +from pydantic import Field, RootModel ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] -class AnyOfColor(BaseModel): + +class AnyOfColor(RootModel[Union[List[int], str]]): """ Any of RGB array, RGBA array, or hex string. """ - # data type: List[int] - anyof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") - # data type: List[int] - anyof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") - # data type: str - anyof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") - if TYPE_CHECKING: - actual_instance: Optional[Union[List[int], str]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { "List[int]", "str" } - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfColor.model_construct() - error_messages = [] - # validate data type: List[int] - try: - instance.anyof_schema_1_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: List[int] - try: - instance.anyof_schema_2_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.anyof_schema_3_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return v + root: Union[List[int], str] = Field( + ... + ) + + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ + + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Self: - return cls.from_json(json.dumps(obj)) + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - # deserialize data into List[int] - try: - # validation - instance.anyof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_1_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into List[int] - try: - # validation - instance.anyof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_2_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.anyof_schema_3_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_3_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) + return self.model_dump_json(by_alias=True, exclude_none=True) - def to_dict(self) -> Optional[Union[Dict[str, Any], List[int], str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py index c949e136f415..a632d3c382d6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -from inspect import getfullargspec -import json import pprint import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator @@ -23,112 +21,56 @@ from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field +from pydantic import Field, RootModel ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] -class AnyOfPig(BaseModel): + +class AnyOfPig(RootModel[Union[BasquePig, DanishPig]]): """ AnyOfPig """ - # data type: BasquePig - anyof_schema_1_validator: Optional[BasquePig] = None - # data type: DanishPig - anyof_schema_2_validator: Optional[DanishPig] = None - if TYPE_CHECKING: - actual_instance: Optional[Union[BasquePig, DanishPig]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { "BasquePig", "DanishPig" } - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfPig.model_construct() - error_messages = [] - # validate data type: BasquePig - if not isinstance(v, BasquePig): - error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") - else: - return v - - # validate data type: DanishPig - if not isinstance(v, DanishPig): - error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") - else: - return v - - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return v + root: Union[BasquePig, DanishPig] = Field( + ... + ) + + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ + + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Self: - return cls.from_json(json.dumps(obj)) + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - # anyof_schema_1_validator: Optional[BasquePig] = None - try: - instance.actual_instance = BasquePig.from_json(json_str) - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # anyof_schema_2_validator: Optional[DanishPig] = None - try: - instance.actual_instance = DanishPig.from_json(json_str) - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) + return self.model_dump_json(by_alias=True, exclude_none=True) - def to_dict(self) -> Optional[Union[Dict[str, Any], BasquePig, DanishPig]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py index 80d4aa689164..2607cb555897 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfArrayOfModel(BaseModel): """ @@ -38,76 +39,27 @@ class ArrayOfArrayOfModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) - _items = [] - if self.another_property: - for _item_another_property in self.another_property: - if _item_another_property: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] - ) - _dict['another_property'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "another_property": [ - [Tag.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["another_property"] - ] if obj.get("another_property") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py index 847ae88c4ffa..b3502813e131 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictFloat from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfArrayOfNumberOnly(BaseModel): """ @@ -37,64 +38,27 @@ class ArrayOfArrayOfNumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfNumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfNumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "ArrayArrayNumber": obj.get("ArrayArrayNumber") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py index 4634914c33eb..40b76b10e2e8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictFloat from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfNumberOnly(BaseModel): """ @@ -37,64 +38,27 @@ class ArrayOfNumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfNumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfNumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "ArrayNumber": obj.get("ArrayNumber") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py index 9cadd4e7beb7..1ef35ed4290a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py @@ -22,7 +22,8 @@ from typing_extensions import Annotated from petstore_api.models.read_only_first import ReadOnlyFirst from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayTest(BaseModel): """ @@ -42,79 +43,27 @@ class ArrayTest(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) - _items = [] - if self.array_array_of_model: - for _item_array_array_of_model in self.array_array_of_model: - if _item_array_array_of_model: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] - ) - _dict['array_array_of_model'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "array_of_string": obj.get("array_of_string"), - "array_of_nullable_float": obj.get("array_of_nullable_float"), - "array_array_of_integer": obj.get("array_array_of_integer"), - "array_array_of_model": [ - [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["array_array_of_model"] - ] if obj.get("array_array_of_model") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py index 40b49a2fca7f..6c414fe72920 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -60,59 +61,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[PrimitiveString, Info]]: - """Create an instance of BaseDiscriminator from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[PrimitiveString, Info]]: - """Create an instance of BaseDiscriminator from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'PrimitiveString': - return import_module("petstore_api.models.primitive_string").PrimitiveString.from_dict(obj) - if object_type == 'Info': - return import_module("petstore_api.models.info").Info.from_dict(obj) - - raise ValueError("BaseDiscriminator failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py index 4a5b9e3bcb9d..ef9d50223015 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class BasquePig(BaseModel): """ @@ -38,65 +39,27 @@ class BasquePig(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of BasquePig from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of BasquePig from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py index 289d9d4670ab..c81fd1e1c2ec 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Bathing(BaseModel): """ Bathing """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning_deep'] = Field( + ..., + description="task_name of the Bathing", + alias="task_name" + ) + function_name: Literal['care_nourish'] = Field( + ..., + description="function_name of the Bathing", + alias="function_name" + ) content: StrictStr additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -53,66 +62,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Bathing from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Bathing from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py index d98aa21e532d..e672f06cf876 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Capitalization(BaseModel): """ @@ -42,69 +43,27 @@ class Capitalization(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Capitalization from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Capitalization from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "smallCamel": obj.get("smallCamel"), - "CapitalCamel": obj.get("CapitalCamel"), - "small_Snake": obj.get("small_Snake"), - "Capital_Snake": obj.get("Capital_Snake"), - "SCA_ETH_Flow_Points": obj.get("SCA_ETH_Flow_Points"), - "ATT_NAME": obj.get("ATT_NAME") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py index 86002178c904..2ab12e0b0b08 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Cat(Animal): """ @@ -38,66 +39,27 @@ class Cat(Animal): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Cat from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Cat from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") if obj.get("color") is not None else 'red', - "declawed": obj.get("declawed") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py index c659f1845726..a832b700194a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Category(BaseModel): """ @@ -38,65 +39,27 @@ class Category(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Category from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Category from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") if obj.get("name") is not None else 'default-name' - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py index d3b6cbe57ea1..c08dfce51988 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CircularAllOfRef(BaseModel): """ @@ -38,73 +39,28 @@ class CircularAllOfRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CircularAllOfRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in second_circular_all_of_ref (list) - _items = [] - if self.second_circular_all_of_ref: - for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: - if _item_second_circular_all_of_ref: - _items.append(_item_second_circular_all_of_ref.to_dict()) - _dict['secondCircularAllOfRef'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CircularAllOfRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name"), - "secondCircularAllOfRef": [SecondCircularAllOfRef.from_dict(_item) for _item in obj["secondCircularAllOfRef"]] if obj.get("secondCircularAllOfRef") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py index 8c118f3c09b2..a4397f923a4b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CircularReferenceModel(BaseModel): """ @@ -38,69 +39,28 @@ class CircularReferenceModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CircularReferenceModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested - if self.nested: - _dict['nested'] = self.nested.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CircularReferenceModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested": FirstRef.from_dict(obj["nested"]) if obj.get("nested") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.first_ref import FirstRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py index 06f8f91b83cb..a0db951aaa5e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ClassModel(BaseModel): """ @@ -37,64 +38,27 @@ class ClassModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ClassModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ClassModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_class": obj.get("_class") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py index d3376d62357b..5a12db40db07 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Client(BaseModel): """ @@ -37,64 +38,27 @@ class Client(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Client from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Client from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "client": obj.get("client") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py index bb740fb597d4..5197fe58ecc6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py @@ -18,150 +18,55 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] -class Color(BaseModel): +class Color(RootModel[Union[List[int], str]]): """ RGB array, RGBA array, or hex string. """ - # data type: List[int] - oneof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") - # data type: List[int] - oneof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") - # data type: str - oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") - actual_instance: Optional[Union[List[int], str]] = None - one_of_schemas: Set[str] = { "List[int]", "str" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[List[int], str, None] = Field( + None ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - if v is None: - return v - - instance = Color.model_construct() - error_messages = [] - match = 0 - # validate data type: List[int] - try: - instance.oneof_schema_1_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: List[int] - try: - instance.oneof_schema_2_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.oneof_schema_3_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: Optional[str]) -> Self: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - if json_str is None: - return instance - - error_messages = [] - match = 0 - - # deserialize data into List[int] - try: - # validation - instance.oneof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_1_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into List[int] - try: - # validation - instance.oneof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_2_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.oneof_schema_3_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_3_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], List[int], str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py index ce6a70327b1a..17379d6ff774 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py @@ -22,7 +22,8 @@ from typing import Any, ClassVar, Dict, List, Union from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -61,60 +62,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[HuntingDog]]: - """Create an instance of Creature from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of info - if self.info: - _dict['info'] = self.info.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[HuntingDog]]: - """Create an instance of Creature from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'HuntingDog': - return import_module("petstore_api.models.hunting_dog").HuntingDog.from_dict(obj) - - raise ValueError("Creature failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py index e7fef158a580..33414bb2e4f6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CreatureInfo(BaseModel): """ @@ -37,64 +38,27 @@ class CreatureInfo(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CreatureInfo from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CreatureInfo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py index df4a80d33908..b2e7e8e9c884 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DanishPig(BaseModel): """ @@ -38,65 +39,27 @@ class DanishPig(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DanishPig from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DanishPig from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "size": obj.get("size") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py index ad0ec89a5b7a..eeed19fe0293 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DeprecatedObject(BaseModel): """ @@ -37,64 +38,27 @@ class DeprecatedObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DeprecatedObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DeprecatedObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py index 9723d2e28c74..23c07b3cc8cd 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List from petstore_api.models.discriminator_all_of_super import DiscriminatorAllOfSuper from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DiscriminatorAllOfSub(DiscriminatorAllOfSuper): """ @@ -37,64 +38,27 @@ class DiscriminatorAllOfSub(DiscriminatorAllOfSuper): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DiscriminatorAllOfSub from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DiscriminatorAllOfSub from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "elementType": obj.get("elementType") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py index e3d62831065a..424c25871dc8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -59,57 +60,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[DiscriminatorAllOfSub]]: - """Create an instance of DiscriminatorAllOfSuper from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[DiscriminatorAllOfSub]]: - """Create an instance of DiscriminatorAllOfSuper from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'DiscriminatorAllOfSub': - return import_module("petstore_api.models.discriminator_all_of_sub").DiscriminatorAllOfSub.from_dict(obj) - - raise ValueError("DiscriminatorAllOfSuper failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py index cde0f5d27e0c..ab08540bc824 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Dog(Animal): """ @@ -38,66 +39,27 @@ class Dog(Animal): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Dog from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Dog from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") if obj.get("color") is not None else 'red', - "breed": obj.get("breed") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py index 47fdb81a397a..339439a15b66 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DummyModel(BaseModel): """ @@ -38,69 +39,28 @@ class DummyModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DummyModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of self_ref - if self.self_ref: - _dict['self_ref'] = self.self_ref.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DummyModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "self_ref": SelfReferenceModel.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.self_reference_model import SelfReferenceModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py index 17d3e0afd2df..4727cd9180b5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py @@ -20,14 +20,21 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumArrays(BaseModel): """ EnumArrays """ # noqa: E501 - just_symbol: Optional[StrictStr] = None - array_enum: Optional[List[StrictStr]] = None + just_symbol: Optional[Literal['>=', '$']] = Field( + None, + description="just_symbol of the EnumArrays" + ) + array_enum: Optional[List[Literal['fish', 'crab']]] = Field( + None, + description="array_enum of the EnumArrays" + ) additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["just_symbol", "array_enum"] @@ -59,65 +66,27 @@ def array_enum_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumArrays from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumArrays from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "just_symbol": obj.get("just_symbol"), - "array_enum": obj.get("array_enum") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py index d864e80d0a73..5f3ded3bd569 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.data_output_format import DataOutputFormat from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumRefWithDefaultValue(BaseModel): """ @@ -38,64 +39,27 @@ class EnumRefWithDefaultValue(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumRefWithDefaultValue from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumRefWithDefaultValue from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "report_format": obj.get("report_format") if obj.get("report_format") is not None else DataOutputFormat.JSON - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py index d39c2c95775e..f38e8375d0f8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py @@ -26,19 +26,43 @@ from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumTest(BaseModel): """ EnumTest """ # noqa: E501 - enum_string: Optional[StrictStr] = None - enum_string_required: StrictStr - enum_integer_default: Optional[StrictInt] = 5 - enum_integer: Optional[StrictInt] = None - enum_number: Optional[StrictFloat] = None - enum_string_single_member: Optional[StrictStr] = None - enum_integer_single_member: Optional[StrictInt] = None + enum_string: Optional[Literal['UPPER', 'lower', '']] = Field( + None, + description="enum_string of the EnumTest" + ) + enum_string_required: Literal['UPPER', 'lower', ''] = Field( + ..., + description="enum_string_required of the EnumTest" + ) + enum_integer_default: Optional[Literal[1, 5, 14]] = Field( + None, + description="enum_integer_default of the EnumTest" + ) + enum_integer: Optional[Literal[1, -1]] = Field( + None, + description="enum_integer of the EnumTest" + ) + enum_number: Optional[Literal[1.1, -1.2]] = Field( + None, + description="enum_number of the EnumTest" + ) + enum_string_single_member: Literal['abc'] = Field( + None, + description="enum_string_single_member of the EnumTest", + alias="enum_string_single_member" + ) + enum_integer_single_member: Literal['100'] = Field( + None, + description="enum_integer_single_member of the EnumTest", + alias="enum_integer_single_member" + ) outer_enum: Optional[OuterEnum] = Field(default=None, alias="outerEnum") outer_enum_integer: Optional[OuterEnumInteger] = Field(default=None, alias="outerEnumInteger") outer_enum_default_value: Optional[OuterEnumDefaultValue] = Field(default=OuterEnumDefaultValue.PLACED, alias="outerEnumDefaultValue") @@ -122,81 +146,27 @@ def enum_integer_single_member_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if outer_enum (nullable) is None - # and model_fields_set contains the field - if self.outer_enum is None and "outer_enum" in self.model_fields_set: - _dict['outerEnum'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "enum_string": obj.get("enum_string"), - "enum_string_required": obj.get("enum_string_required"), - "enum_integer_default": obj.get("enum_integer_default") if obj.get("enum_integer_default") is not None else 5, - "enum_integer": obj.get("enum_integer"), - "enum_number": obj.get("enum_number"), - "enum_string_single_member": obj.get("enum_string_single_member"), - "enum_integer_single_member": obj.get("enum_integer_single_member"), - "outerEnum": obj.get("outerEnum"), - "outerEnumInteger": obj.get("outerEnumInteger"), - "outerEnumDefaultValue": obj.get("outerEnumDefaultValue") if obj.get("outerEnumDefaultValue") is not None else OuterEnumDefaultValue.PLACED, - "outerEnumIntegerDefaultValue": obj.get("outerEnumIntegerDefaultValue") if obj.get("outerEnumIntegerDefaultValue") is not None else OuterEnumIntegerDefaultValue.NUMBER_0, - "enumNumberVendorExt": obj.get("enumNumberVendorExt"), - "enumStringVendorExt": obj.get("enumStringVendorExt") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py index 5c406bc9e65e..bf9365e5b6bc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Feeding(BaseModel): """ Feeding """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning'] = Field( + ..., + description="task_name of the Feeding", + alias="task_name" + ) + function_name: Literal['care_nourish'] = Field( + ..., + description="function_name of the Feeding", + alias="function_name" + ) content: StrictStr additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -53,66 +62,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Feeding from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Feeding from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py index 4c661cadabc4..ee16b0236916 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class File(BaseModel): """ @@ -37,64 +38,27 @@ class File(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of File from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of File from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "sourceURI": obj.get("sourceURI") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py index 09a543010f4d..ed0e54ef78e5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.file import File from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FileSchemaTestClass(BaseModel): """ @@ -39,75 +40,27 @@ class FileSchemaTestClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FileSchemaTestClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of file - if self.file: - _dict['file'] = self.file.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in files (list) - _items = [] - if self.files: - for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) - _dict['files'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FileSchemaTestClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "file": File.from_dict(obj["file"]) if obj.get("file") is not None else None, - "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py index 7680dfdf418c..0fb22f81f548 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FirstRef(BaseModel): """ @@ -38,69 +39,28 @@ class FirstRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FirstRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of self_ref - if self.self_ref: - _dict['self_ref'] = self.self_ref.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FirstRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "self_ref": SecondRef.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.second_ref import SecondRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py index 81e3839ea17c..441022bc8977 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Foo(BaseModel): """ @@ -37,64 +38,27 @@ class Foo(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Foo from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Foo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar") if obj.get("bar") is not None else 'bar' - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py index 4cd23db39125..deac653ae358 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.foo import Foo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FooGetDefaultResponse(BaseModel): """ @@ -38,67 +39,27 @@ class FooGetDefaultResponse(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FooGetDefaultResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of string - if self.string: - _dict['string'] = self.string.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FooGetDefaultResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "string": Foo.from_dict(obj["string"]) if obj.get("string") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py index 4aca97f91c48..2960e7f390c8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py @@ -24,7 +24,8 @@ from typing_extensions import Annotated from uuid import UUID from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FormatTest(BaseModel): """ @@ -97,80 +98,27 @@ def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FormatTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FormatTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "integer": obj.get("integer"), - "int32": obj.get("int32"), - "int64": obj.get("int64"), - "number": obj.get("number"), - "float": obj.get("float"), - "double": obj.get("double"), - "decimal": obj.get("decimal"), - "string": obj.get("string"), - "string_with_double_quote_pattern": obj.get("string_with_double_quote_pattern"), - "byte": obj.get("byte"), - "binary": obj.get("binary"), - "date": obj.get("date"), - "dateTime": obj.get("dateTime"), - "uuid": obj.get("uuid"), - "password": obj.get("password"), - "pattern_with_digits": obj.get("pattern_with_digits"), - "pattern_with_digits_and_delimiter": obj.get("pattern_with_digits_and_delimiter") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py index 77360fedbae5..970814db675e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HasOnlyReadOnly(BaseModel): """ @@ -38,69 +39,27 @@ class HasOnlyReadOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HasOnlyReadOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * OpenAPI `readOnly` fields are excluded. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "bar", - "foo", - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HasOnlyReadOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar"), - "foo": obj.get("foo") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py index 59f444aedaa3..658fdb690194 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HealthCheckResult(BaseModel): """ @@ -37,69 +38,27 @@ class HealthCheckResult(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HealthCheckResult from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if nullable_message (nullable) is None - # and model_fields_set contains the field - if self.nullable_message is None and "nullable_message" in self.model_fields_set: - _dict['NullableMessage'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HealthCheckResult from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "NullableMessage": obj.get("NullableMessage") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py index f7d03f4044ea..05c5aef54690 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py @@ -22,7 +22,8 @@ from petstore_api.models.creature import Creature from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HuntingDog(Creature): """ @@ -39,69 +40,27 @@ class HuntingDog(Creature): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HuntingDog from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of info - if self.info: - _dict['info'] = self.info.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HuntingDog from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "info": CreatureInfo.from_dict(obj["info"]) if obj.get("info") is not None else None, - "type": obj.get("type"), - "isTrained": obj.get("isTrained") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py index 94e663b3aaab..0eb710f31a1c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.base_discriminator import BaseDiscriminator from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Info(BaseDiscriminator): """ @@ -38,68 +39,27 @@ class Info(BaseDiscriminator): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Info from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of val - if self.val: - _dict['val'] = self.val.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Info from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_typeName": obj.get("_typeName"), - "val": BaseDiscriminator.from_dict(obj["val"]) if obj.get("val") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py index b43fa8b19fef..7085980c441b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class InnerDictWithProperty(BaseModel): """ @@ -37,64 +38,27 @@ class InnerDictWithProperty(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of InnerDictWithProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of InnerDictWithProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "aProperty": obj.get("aProperty") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py index e4a81ff70006..37d9c2b8d285 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class InputAllOf(BaseModel): """ @@ -38,76 +39,27 @@ class InputAllOf(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of InputAllOf from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) - _field_dict = {} - if self.some_data: - for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - _dict['some_data'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of InputAllOf from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "some_data": dict( - (_k, Tag.from_dict(_v)) - for _k, _v in obj["some_data"].items() - ) - if obj.get("some_data") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py index f2a5a0a2d4a3..c66bf1ab9772 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py @@ -18,127 +18,55 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] -class IntOrString(BaseModel): +class IntOrString(RootModel[Union[int, str]]): """ IntOrString """ - # data type: int - oneof_schema_1_validator: Optional[Annotated[int, Field(strict=True, ge=10)]] = None - # data type: str - oneof_schema_2_validator: Optional[StrictStr] = None - actual_instance: Optional[Union[int, str]] = None - one_of_schemas: Set[str] = { "int", "str" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[int, str] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = IntOrString.model_construct() - error_messages = [] - match = 0 - # validate data type: int - try: - instance.oneof_schema_1_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.oneof_schema_2_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into int - try: - # validation - instance.oneof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_1_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.oneof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_2_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py index e00f3d820b88..12892c065284 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ListClass(BaseModel): """ @@ -37,64 +38,27 @@ class ListClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ListClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ListClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "123-list": obj.get("123-list") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py index 68816ab29531..c5668fc1865f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MapOfArrayOfModel(BaseModel): """ @@ -38,80 +39,27 @@ class MapOfArrayOfModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MapOfArrayOfModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array) - _field_dict_of_array = {} - if self.shop_id_to_org_online_lip_map: - for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ - _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] - ] - _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MapOfArrayOfModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "shopIdToOrgOnlineLipMap": dict( - (_k, - [Tag.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("shopIdToOrgOnlineLipMap", {}).items() - ) - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py index 4cefd36427f9..a8fee7d14e6f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py @@ -20,14 +20,18 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MapTest(BaseModel): """ MapTest """ # noqa: E501 map_map_of_string: Optional[Dict[str, Dict[str, StrictStr]]] = None - map_of_enum_string: Optional[Dict[str, StrictStr]] = None + map_of_enum_string: Optional[Literal['UPPER', 'lower']] = Field( + None, + description="map_of_enum_string of the MapTest" + ) direct_map: Optional[Dict[str, StrictBool]] = None indirect_map: Optional[Dict[str, StrictBool]] = None additional_properties: Dict[str, Any] = {} @@ -51,67 +55,27 @@ def map_of_enum_string_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MapTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MapTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "map_map_of_string": obj.get("map_map_of_string"), - "map_of_enum_string": obj.get("map_of_enum_string"), - "direct_map": obj.get("direct_map"), - "indirect_map": obj.get("indirect_map") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py index c21f442bb798..f2b040b8b0d9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -23,7 +23,8 @@ from uuid import UUID from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): """ @@ -42,78 +43,27 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in map (dict) - _field_dict = {} - if self.map: - for _key_map in self.map: - if self.map[_key_map]: - _field_dict[_key_map] = self.map[_key_map].to_dict() - _dict['map'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "uuid": obj.get("uuid"), - "dateTime": obj.get("dateTime"), - "map": dict( - (_k, Animal.from_dict(_v)) - for _k, _v in obj["map"].items() - ) - if obj.get("map") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py index 60e43a0e28e6..2ed302bf3dda 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Model200Response(BaseModel): """ @@ -38,65 +39,27 @@ class Model200Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Model200Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Model200Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "class": obj.get("class") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py index 7141160c57d9..5024a3748f4c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelApiResponse(BaseModel): """ @@ -39,66 +40,27 @@ class ModelApiResponse(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelApiResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelApiResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "code": obj.get("code"), - "type": obj.get("type"), - "message": obj.get("message") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py index d7b03848fe16..c383206e7f01 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelField(BaseModel): """ @@ -37,64 +38,27 @@ class ModelField(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelField from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelField from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "field": obj.get("field") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py index 3f2558bc6e7d..a50cfe4de892 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelReturn(BaseModel): """ @@ -37,64 +38,27 @@ class ModelReturn(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelReturn from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelReturn from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "return": obj.get("return") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py index 80fa67f8a11c..776597336558 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py @@ -22,7 +22,8 @@ from petstore_api.models.file import File from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MultiArrays(BaseModel): """ @@ -40,79 +41,27 @@ class MultiArrays(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MultiArrays from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - # override the default output from pydantic by calling `to_dict()` of each item in files (list) - _items = [] - if self.files: - for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) - _dict['files'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MultiArrays from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py index 01b02f834137..0a142fc76a55 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Name(BaseModel): """ @@ -40,71 +41,27 @@ class Name(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Name from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * OpenAPI `readOnly` fields are excluded. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "snake_case", - "var_123_number", - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Name from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "snake_case": obj.get("snake_case"), - "property": obj.get("property"), - "123Number": obj.get("123Number") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py index cb27fbf691c2..9af5bd4422e9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NullableClass(BaseModel): """ @@ -50,131 +51,27 @@ class NullableClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NullableClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if required_integer_prop (nullable) is None - # and model_fields_set contains the field - if self.required_integer_prop is None and "required_integer_prop" in self.model_fields_set: - _dict['required_integer_prop'] = None - - # set to None if integer_prop (nullable) is None - # and model_fields_set contains the field - if self.integer_prop is None and "integer_prop" in self.model_fields_set: - _dict['integer_prop'] = None - - # set to None if number_prop (nullable) is None - # and model_fields_set contains the field - if self.number_prop is None and "number_prop" in self.model_fields_set: - _dict['number_prop'] = None - - # set to None if boolean_prop (nullable) is None - # and model_fields_set contains the field - if self.boolean_prop is None and "boolean_prop" in self.model_fields_set: - _dict['boolean_prop'] = None - - # set to None if string_prop (nullable) is None - # and model_fields_set contains the field - if self.string_prop is None and "string_prop" in self.model_fields_set: - _dict['string_prop'] = None - - # set to None if date_prop (nullable) is None - # and model_fields_set contains the field - if self.date_prop is None and "date_prop" in self.model_fields_set: - _dict['date_prop'] = None - - # set to None if datetime_prop (nullable) is None - # and model_fields_set contains the field - if self.datetime_prop is None and "datetime_prop" in self.model_fields_set: - _dict['datetime_prop'] = None - - # set to None if array_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.array_nullable_prop is None and "array_nullable_prop" in self.model_fields_set: - _dict['array_nullable_prop'] = None - - # set to None if array_and_items_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.array_and_items_nullable_prop is None and "array_and_items_nullable_prop" in self.model_fields_set: - _dict['array_and_items_nullable_prop'] = None - - # set to None if object_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.object_nullable_prop is None and "object_nullable_prop" in self.model_fields_set: - _dict['object_nullable_prop'] = None - - # set to None if object_and_items_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.object_and_items_nullable_prop is None and "object_and_items_nullable_prop" in self.model_fields_set: - _dict['object_and_items_nullable_prop'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NullableClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "required_integer_prop": obj.get("required_integer_prop"), - "integer_prop": obj.get("integer_prop"), - "number_prop": obj.get("number_prop"), - "boolean_prop": obj.get("boolean_prop"), - "string_prop": obj.get("string_prop"), - "date_prop": obj.get("date_prop"), - "datetime_prop": obj.get("datetime_prop"), - "array_nullable_prop": obj.get("array_nullable_prop"), - "array_and_items_nullable_prop": obj.get("array_and_items_nullable_prop"), - "array_items_nullable": obj.get("array_items_nullable"), - "object_nullable_prop": obj.get("object_nullable_prop"), - "object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"), - "object_items_nullable": obj.get("object_items_nullable") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py index e73cd1509c90..97e118cfed4b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NullableProperty(BaseModel): """ @@ -49,70 +50,27 @@ def name_validate_regular_expression(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NullableProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if name (nullable) is None - # and model_fields_set contains the field - if self.name is None and "name" in self.model_fields_set: - _dict['name'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NullableProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py index f74010e908bb..4cbf63e51f9f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictFloat from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NumberOnly(BaseModel): """ @@ -37,64 +38,27 @@ class NumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "JustNumber": obj.get("JustNumber") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py index 097bdd34e2be..19e4e0a5b32f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictBool from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ObjectToTestAdditionalProperties(BaseModel): """ @@ -37,64 +38,27 @@ class ObjectToTestAdditionalProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ObjectToTestAdditionalProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ObjectToTestAdditionalProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "property": obj.get("property") if obj.get("property") is not None else False - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py index 0c0cc840680b..94e9f98754b1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.deprecated_object import DeprecatedObject from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ObjectWithDeprecatedFields(BaseModel): """ @@ -41,70 +42,27 @@ class ObjectWithDeprecatedFields(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ObjectWithDeprecatedFields from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of deprecated_ref - if self.deprecated_ref: - _dict['deprecatedRef'] = self.deprecated_ref.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ObjectWithDeprecatedFields from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "uuid": obj.get("uuid"), - "id": obj.get("id"), - "deprecatedRef": DeprecatedObject.from_dict(obj["deprecatedRef"]) if obj.get("deprecatedRef") is not None else None, - "bars": obj.get("bars") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py index f180178737db..bdbbebe0e1c4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py @@ -19,119 +19,55 @@ from typing import Any, List, Optional from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] -class OneOfEnumString(BaseModel): +class OneOfEnumString(RootModel[Union[EnumString1, EnumString2]]): """ oneOf enum strings """ - # data type: EnumString1 - oneof_schema_1_validator: Optional[EnumString1] = None - # data type: EnumString2 - oneof_schema_2_validator: Optional[EnumString2] = None - actual_instance: Optional[Union[EnumString1, EnumString2]] = None - one_of_schemas: Set[str] = { "EnumString1", "EnumString2" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[EnumString1, EnumString2] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = OneOfEnumString.model_construct() - error_messages = [] - match = 0 - # validate data type: EnumString1 - if not isinstance(v, EnumString1): - error_messages.append(f"Error! Input type `{type(v)}` is not `EnumString1`") - else: - match += 1 - # validate data type: EnumString2 - if not isinstance(v, EnumString2): - error_messages.append(f"Error! Input type `{type(v)}` is not `EnumString2`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into EnumString1 - try: - instance.actual_instance = EnumString1.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into EnumString2 - try: - instance.actual_instance = EnumString2.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], EnumString1, EnumString2]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py index 12dd1ef117d2..a5c50a094a0b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Order(BaseModel): """ @@ -31,7 +32,10 @@ class Order(BaseModel): pet_id: Optional[StrictInt] = Field(default=None, alias="petId") quantity: Optional[StrictInt] = None ship_date: Optional[datetime] = Field(default=None, alias="shipDate") - status: Optional[StrictStr] = Field(default=None, description="Order Status") + status: Optional[Literal['placed', 'approved', 'delivered']] = Field( + None, + description="Order Status" + ) complete: Optional[StrictBool] = False additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["id", "petId", "quantity", "shipDate", "status", "complete"] @@ -53,69 +57,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Order from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Order from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "petId": obj.get("petId"), - "quantity": obj.get("quantity"), - "shipDate": obj.get("shipDate"), - "status": obj.get("status"), - "complete": obj.get("complete") if obj.get("complete") is not None else False - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py index 5242660b636b..c137aa6b2f4f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class OuterComposite(BaseModel): """ @@ -39,66 +40,27 @@ class OuterComposite(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OuterComposite from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OuterComposite from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "my_number": obj.get("my_number"), - "my_string": obj.get("my_string"), - "my_boolean": obj.get("my_boolean") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py index f8d215a21c94..bab2f225fba6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py @@ -22,7 +22,8 @@ from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class OuterObjectWithEnumProperty(BaseModel): """ @@ -40,70 +41,27 @@ class OuterObjectWithEnumProperty(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OuterObjectWithEnumProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if str_value (nullable) is None - # and model_fields_set contains the field - if self.str_value is None and "str_value" in self.model_fields_set: - _dict['str_value'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OuterObjectWithEnumProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "str_value": obj.get("str_value"), - "value": obj.get("value") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py index 8a30758ab8fd..ec9d1a338e3b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Parent(BaseModel): """ @@ -38,76 +39,27 @@ class Parent(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Parent from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) - _field_dict = {} - if self.optional_dict: - for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - _dict['optionalDict'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Parent from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "optionalDict": dict( - (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj["optionalDict"].items() - ) - if obj.get("optionalDict") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py index 509693dd1441..1b3a5d2f2f4c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ParentWithOptionalDict(BaseModel): """ @@ -38,76 +39,27 @@ class ParentWithOptionalDict(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ParentWithOptionalDict from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) - _field_dict = {} - if self.optional_dict: - for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - _dict['optionalDict'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ParentWithOptionalDict from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "optionalDict": dict( - (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj["optionalDict"].items() - ) - if obj.get("optionalDict") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py index 48f0c2fceeb7..0e1a9bf177f2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py @@ -23,7 +23,8 @@ from petstore_api.models.category import Category from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Pet(BaseModel): """ @@ -34,7 +35,10 @@ class Pet(BaseModel): name: StrictStr photo_urls: Annotated[List[StrictStr], Field(min_length=0)] = Field(alias="photoUrls") tags: Optional[List[Tag]] = None - status: Optional[StrictStr] = Field(default=None, description="pet status in the store") + status: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["id", "category", "name", "photoUrls", "tags", "status"] @@ -55,79 +59,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Pet from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of category - if self.category: - _dict['category'] = self.category.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Pet from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, - "name": obj.get("name"), - "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "status": obj.get("status") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py index 06798245b8fe..6646e6d477cd 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py @@ -19,137 +19,55 @@ from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] -class Pig(BaseModel): +class Pig(RootModel[Union[BasquePig, DanishPig]]): """ Pig """ - # data type: BasquePig - oneof_schema_1_validator: Optional[BasquePig] = None - # data type: DanishPig - oneof_schema_2_validator: Optional[DanishPig] = None - actual_instance: Optional[Union[BasquePig, DanishPig]] = None - one_of_schemas: Set[str] = { "BasquePig", "DanishPig" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[BasquePig, DanishPig] = Field( + ..., discriminator="class_name" ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - discriminator_value_class_map: Dict[str, str] = { - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = Pig.model_construct() - error_messages = [] - match = 0 - # validate data type: BasquePig - if not isinstance(v, BasquePig): - error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") - else: - match += 1 - # validate data type: DanishPig - if not isinstance(v, DanishPig): - error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # use oneOf discriminator to lookup the data type - _data_type = json.loads(json_str).get("className") - if not _data_type: - raise ValueError("Failed to lookup data type from the field `className` in the input.") - - # check if data type is `BasquePig` - if _data_type == "BasquePig": - instance.actual_instance = BasquePig.from_json(json_str) - return instance - - # check if data type is `DanishPig` - if _data_type == "DanishPig": - instance.actual_instance = DanishPig.from_json(json_str) - return instance - - # deserialize data into BasquePig - try: - instance.actual_instance = BasquePig.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into DanishPig - try: - instance.actual_instance = DanishPig.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], BasquePig, DanishPig]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py index 74efce9a4d06..f667018ed881 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.type import Type from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PonySizes(BaseModel): """ @@ -38,64 +39,27 @@ class PonySizes(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PonySizes from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PonySizes from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "type": obj.get("type") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py index 76eb72a941bf..7c16bfeec116 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PoopCleaning(BaseModel): """ PoopCleaning """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning'] = Field( + ..., + description="task_name of the PoopCleaning", + alias="task_name" + ) + function_name: Literal['care'] = Field( + ..., + description="function_name of the PoopCleaning", + alias="function_name" + ) content: StrictStr additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -53,66 +62,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PoopCleaning from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PoopCleaning from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py index f7a971519f2f..97e03f355280 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.base_discriminator import BaseDiscriminator from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PrimitiveString(BaseDiscriminator): """ @@ -38,65 +39,27 @@ class PrimitiveString(BaseDiscriminator): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PrimitiveString from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PrimitiveString from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_typeName": obj.get("_typeName"), - "_value": obj.get("_value") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py index 0da2a14293de..11bab78a3c96 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PropertyMap(BaseModel): """ @@ -38,76 +39,27 @@ class PropertyMap(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PropertyMap from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) - _field_dict = {} - if self.some_data: - for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - _dict['some_data'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PropertyMap from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "some_data": dict( - (_k, Tag.from_dict(_v)) - for _k, _v in obj["some_data"].items() - ) - if obj.get("some_data") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py index d07aef22cd82..5d0eb8d1225c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PropertyNameCollision(BaseModel): """ @@ -39,66 +40,27 @@ class PropertyNameCollision(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PropertyNameCollision from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PropertyNameCollision from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_type": obj.get("_type"), - "type": obj.get("type"), - "type_": obj.get("type_") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py index 5a4155fcfa13..3665454efc1d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ReadOnlyFirst(BaseModel): """ @@ -38,67 +39,27 @@ class ReadOnlyFirst(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReadOnlyFirst from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "bar", - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReadOnlyFirst from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar"), - "baz": obj.get("baz") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py index 13d6327314c3..b564e6d2ac79 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SecondCircularAllOfRef(BaseModel): """ @@ -38,73 +39,28 @@ class SecondCircularAllOfRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SecondCircularAllOfRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in circular_all_of_ref (list) - _items = [] - if self.circular_all_of_ref: - for _item_circular_all_of_ref in self.circular_all_of_ref: - if _item_circular_all_of_ref: - _items.append(_item_circular_all_of_ref.to_dict()) - _dict['circularAllOfRef'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SecondCircularAllOfRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name"), - "circularAllOfRef": [CircularAllOfRef.from_dict(_item) for _item in obj["circularAllOfRef"]] if obj.get("circularAllOfRef") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.circular_all_of_ref import CircularAllOfRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py index 701e0dccaacf..52d3347704b7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SecondRef(BaseModel): """ @@ -38,69 +39,28 @@ class SecondRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SecondRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of circular_ref - if self.circular_ref: - _dict['circular_ref'] = self.circular_ref.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SecondRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "circular_ref": CircularReferenceModel.from_dict(obj["circular_ref"]) if obj.get("circular_ref") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.circular_reference_model import CircularReferenceModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py index 0273b10dada6..6c11409dee00 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SelfReferenceModel(BaseModel): """ @@ -38,69 +39,28 @@ class SelfReferenceModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SelfReferenceModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested - if self.nested: - _dict['nested'] = self.nested.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SelfReferenceModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested": DummyModel.from_dict(obj["nested"]) if obj.get("nested") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.dummy_model import DummyModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py index 84686054875a..ebbf9463952c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SpecialModelName(BaseModel): """ @@ -37,64 +38,27 @@ class SpecialModelName(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SpecialModelName from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SpecialModelName from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "$special[property.name]": obj.get("$special[property.name]") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py index e43761d33dfc..8319ec235809 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.category import Category from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SpecialName(BaseModel): """ @@ -29,7 +30,10 @@ class SpecialName(BaseModel): """ # noqa: E501 var_property: Optional[StrictInt] = Field(default=None, alias="property") var_async: Optional[Category] = Field(default=None, alias="async") - var_schema: Optional[StrictStr] = Field(default=None, description="pet status in the store", alias="schema") + var_schema: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["property", "async", "schema"] @@ -50,69 +54,27 @@ def var_schema_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SpecialName from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of var_async - if self.var_async: - _dict['async'] = self.var_async.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SpecialName from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "property": obj.get("property"), - "async": Category.from_dict(obj["async"]) if obj.get("async") is not None else None, - "schema": obj.get("schema") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py index b3893aecb683..2a95cc94529f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tag(BaseModel): """ @@ -38,65 +39,27 @@ class Tag(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tag from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tag from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py index a8e0fa11ff84..19ceec24044b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py @@ -22,7 +22,8 @@ from uuid import UUID from petstore_api.models.task_activity import TaskActivity from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Task(BaseModel): """ @@ -40,68 +41,27 @@ class Task(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Task from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of activity - if self.activity: - _dict['activity'] = self.activity.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Task from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "activity": TaskActivity.from_dict(obj["activity"]) if obj.get("activity") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py index cc1e1fc5a60f..39a1c0bbc375 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py @@ -20,132 +20,55 @@ from petstore_api.models.bathing import Bathing from petstore_api.models.feeding import Feeding from petstore_api.models.poop_cleaning import PoopCleaning -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] -class TaskActivity(BaseModel): +class TaskActivity(RootModel[Union[Bathing, Feeding, PoopCleaning]]): """ TaskActivity """ - # data type: PoopCleaning - oneof_schema_1_validator: Optional[PoopCleaning] = None - # data type: Feeding - oneof_schema_2_validator: Optional[Feeding] = None - # data type: Bathing - oneof_schema_3_validator: Optional[Bathing] = None - actual_instance: Optional[Union[Bathing, Feeding, PoopCleaning]] = None - one_of_schemas: Set[str] = { "Bathing", "Feeding", "PoopCleaning" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[Bathing, Feeding, PoopCleaning] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = TaskActivity.model_construct() - error_messages = [] - match = 0 - # validate data type: PoopCleaning - if not isinstance(v, PoopCleaning): - error_messages.append(f"Error! Input type `{type(v)}` is not `PoopCleaning`") - else: - match += 1 - # validate data type: Feeding - if not isinstance(v, Feeding): - error_messages.append(f"Error! Input type `{type(v)}` is not `Feeding`") - else: - match += 1 - # validate data type: Bathing - if not isinstance(v, Bathing): - error_messages.append(f"Error! Input type `{type(v)}` is not `Bathing`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into PoopCleaning - try: - instance.actual_instance = PoopCleaning.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Feeding - try: - instance.actual_instance = Feeding.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Bathing - try: - instance.actual_instance = Bathing.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], Bathing, Feeding, PoopCleaning]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py index f5fe068c9111..1afe35f8f1ef 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestErrorResponsesWithModel400Response(BaseModel): """ @@ -37,64 +38,27 @@ class TestErrorResponsesWithModel400Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel400Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "reason400": obj.get("reason400") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py index 39e6c512ed3e..91ea69de6d18 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestErrorResponsesWithModel404Response(BaseModel): """ @@ -37,64 +38,27 @@ class TestErrorResponsesWithModel404Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel404Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "reason404": obj.get("reason404") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py index 7b93d84864f2..b8ae3f003698 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): """ @@ -37,64 +38,27 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "someProperty": obj.get("someProperty") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py index 4bff5e699a37..b239642e7959 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py @@ -22,7 +22,8 @@ from petstore_api.models.test_enum import TestEnum from petstore_api.models.test_enum_with_default import TestEnumWithDefault from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestModelWithEnumDefault(BaseModel): """ @@ -32,7 +33,10 @@ class TestModelWithEnumDefault(BaseModel): test_string: Optional[StrictStr] = None test_enum_with_default: Optional[TestEnumWithDefault] = TestEnumWithDefault.ZWEI test_string_with_default: Optional[StrictStr] = 'ahoy matey' - test_inline_defined_enum_with_default: Optional[StrictStr] = 'B' + test_inline_defined_enum_with_default: Optional[Literal['A', 'B', 'C']] = Field( + None, + description="test_inline_defined_enum_with_default of the TestModelWithEnumDefault" + ) additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"] @@ -53,68 +57,27 @@ def test_inline_defined_enum_with_default_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestModelWithEnumDefault from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestModelWithEnumDefault from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "test_enum": obj.get("test_enum"), - "test_string": obj.get("test_string"), - "test_enum_with_default": obj.get("test_enum_with_default") if obj.get("test_enum_with_default") is not None else TestEnumWithDefault.ZWEI, - "test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey', - "test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B' - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py index c31d72482d59..dbdf41c24874 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestObjectForMultipartRequestsRequestMarker(BaseModel): """ @@ -37,64 +38,27 @@ class TestObjectForMultipartRequestsRequestMarker(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestObjectForMultipartRequestsRequestMarker from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py index c2dab004fe1a..17d63717565f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tiger(BaseModel): """ @@ -37,64 +38,27 @@ class Tiger(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tiger from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tiger from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "skill": obj.get("skill") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index e5b5cb4ddeda..7e665d3a2739 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UnnamedDictWithAdditionalModelListProperties(BaseModel): """ @@ -38,80 +39,27 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) - _field_dict_of_array = {} - if self.dict_property: - for _key_dict_property in self.dict_property: - if self.dict_property[_key_dict_property] is not None: - _field_dict_of_array[_key_dict_property] = [ - _item.to_dict() for _item in self.dict_property[_key_dict_property] - ] - _dict['dictProperty'] = _field_dict_of_array - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "dictProperty": dict( - (_k, - [CreatureInfo.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("dictProperty", {}).items() - ) - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index f4c7625325c8..863584646440 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UnnamedDictWithAdditionalStringListProperties(BaseModel): """ @@ -37,64 +38,27 @@ class UnnamedDictWithAdditionalStringListProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "dictProperty": obj.get("dictProperty") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py index 6d79131bfe79..466d550ec22c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UploadFileWithAdditionalPropertiesRequestObject(BaseModel): """ @@ -37,64 +38,27 @@ class UploadFileWithAdditionalPropertiesRequestObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UploadFileWithAdditionalPropertiesRequestObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UploadFileWithAdditionalPropertiesRequestObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py index ceeb6d4ae54c..b47a215064eb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class User(BaseModel): """ @@ -44,71 +45,27 @@ class User(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of User from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of User from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "username": obj.get("username"), - "firstName": obj.get("firstName"), - "lastName": obj.get("lastName"), - "email": obj.get("email"), - "password": obj.get("password"), - "phone": obj.get("phone"), - "userStatus": obj.get("userStatus") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py index eb7e90879e90..c4da6d5004c5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py @@ -22,7 +22,8 @@ from petstore_api.models.one_of_enum_string import OneOfEnumString from petstore_api.models.pig import Pig from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class WithNestedOneOf(BaseModel): """ @@ -41,72 +42,27 @@ class WithNestedOneOf(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of WithNestedOneOf from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested_pig - if self.nested_pig: - _dict['nested_pig'] = self.nested_pig.to_dict() - # override the default output from pydantic by calling `to_dict()` of nested_oneof_enum_string - if self.nested_oneof_enum_string: - _dict['nested_oneof_enum_string'] = self.nested_oneof_enum_string.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of WithNestedOneOf from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested_pig": Pig.from_dict(obj["nested_pig"]) if obj.get("nested_pig") is not None else None, - "nested_oneof_enum_string": OneOfEnumString.from_dict(obj["nested_oneof_enum_string"]) if obj.get("nested_oneof_enum_string") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesAnyType.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesAnyType.md index 314cba3a614c..b94c1e6d7d19 100644 --- a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesAnyType.md +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesAnyType.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_any_type import AdditionalPropert # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesAnyType from a JSON string -additional_properties_any_type_instance = AdditionalPropertiesAnyType.from_json(json) +additional_properties_any_type_instance = AdditionalPropertiesAnyType.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesAnyType.to_json()) +print(additional_properties_any_type_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_any_type_dict = additional_properties_any_type_instance.to_dict() +additional_properties_any_type_dict = additional_properties_any_type_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesAnyType from a dict -additional_properties_any_type_from_dict = AdditionalPropertiesAnyType.from_dict(additional_properties_any_type_dict) +additional_properties_any_type_from_dict = AdditionalPropertiesAnyType.model_validate(additional_properties_any_type_dict) ``` [[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/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md index 8d4c08707f55..4c880d6853e8 100644 --- a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md @@ -16,14 +16,14 @@ from petstore_api.models.additional_properties_class import AdditionalProperties # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesClass from a JSON string -additional_properties_class_instance = AdditionalPropertiesClass.from_json(json) +additional_properties_class_instance = AdditionalPropertiesClass.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesClass.to_json()) +print(additional_properties_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_class_dict = additional_properties_class_instance.to_dict() +additional_properties_class_dict = additional_properties_class_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesClass from a dict -additional_properties_class_from_dict = AdditionalPropertiesClass.from_dict(additional_properties_class_dict) +additional_properties_class_from_dict = AdditionalPropertiesClass.model_validate(additional_properties_class_dict) ``` [[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/AdditionalPropertiesObject.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesObject.md index d647ec64896f..bf6743709338 100644 --- a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesObject.md +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesObject.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_object import AdditionalPropertie # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesObject from a JSON string -additional_properties_object_instance = AdditionalPropertiesObject.from_json(json) +additional_properties_object_instance = AdditionalPropertiesObject.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesObject.to_json()) +print(additional_properties_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_object_dict = additional_properties_object_instance.to_dict() +additional_properties_object_dict = additional_properties_object_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesObject from a dict -additional_properties_object_from_dict = AdditionalPropertiesObject.from_dict(additional_properties_object_dict) +additional_properties_object_from_dict = AdditionalPropertiesObject.model_validate(additional_properties_object_dict) ``` [[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/AdditionalPropertiesWithDescriptionOnly.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithDescriptionOnly.md index 061f5524872b..1cb2a02f7584 100644 --- a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithDescriptionOnly.md +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithDescriptionOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.additional_properties_with_description_only import Addi # TODO update the JSON string below json = "{}" # create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string -additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.from_json(json) +additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.model_validate_json(json) # print the JSON string representation of the object -print(AdditionalPropertiesWithDescriptionOnly.to_json()) +print(additional_properties_with_description_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.to_dict() +additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.model_dump(by_alias=True) # create an instance of AdditionalPropertiesWithDescriptionOnly from a dict -additional_properties_with_description_only_from_dict = AdditionalPropertiesWithDescriptionOnly.from_dict(additional_properties_with_description_only_dict) +additional_properties_with_description_only_from_dict = AdditionalPropertiesWithDescriptionOnly.model_validate(additional_properties_with_description_only_dict) ``` [[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/AllOfSuperModel.md b/samples/openapi3/client/petstore/python/docs/AllOfSuperModel.md index 421a1527f1ef..88cb95097517 100644 --- a/samples/openapi3/client/petstore/python/docs/AllOfSuperModel.md +++ b/samples/openapi3/client/petstore/python/docs/AllOfSuperModel.md @@ -15,14 +15,14 @@ from petstore_api.models.all_of_super_model import AllOfSuperModel # TODO update the JSON string below json = "{}" # create an instance of AllOfSuperModel from a JSON string -all_of_super_model_instance = AllOfSuperModel.from_json(json) +all_of_super_model_instance = AllOfSuperModel.model_validate_json(json) # print the JSON string representation of the object -print(AllOfSuperModel.to_json()) +print(all_of_super_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -all_of_super_model_dict = all_of_super_model_instance.to_dict() +all_of_super_model_dict = all_of_super_model_instance.model_dump(by_alias=True) # create an instance of AllOfSuperModel from a dict -all_of_super_model_from_dict = AllOfSuperModel.from_dict(all_of_super_model_dict) +all_of_super_model_from_dict = AllOfSuperModel.model_validate(all_of_super_model_dict) ``` [[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/AllOfWithSingleRef.md b/samples/openapi3/client/petstore/python/docs/AllOfWithSingleRef.md index 203a4b5da3d5..dd0f755dfe65 100644 --- a/samples/openapi3/client/petstore/python/docs/AllOfWithSingleRef.md +++ b/samples/openapi3/client/petstore/python/docs/AllOfWithSingleRef.md @@ -16,14 +16,14 @@ from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef # TODO update the JSON string below json = "{}" # create an instance of AllOfWithSingleRef from a JSON string -all_of_with_single_ref_instance = AllOfWithSingleRef.from_json(json) +all_of_with_single_ref_instance = AllOfWithSingleRef.model_validate_json(json) # print the JSON string representation of the object -print(AllOfWithSingleRef.to_json()) +print(all_of_with_single_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -all_of_with_single_ref_dict = all_of_with_single_ref_instance.to_dict() +all_of_with_single_ref_dict = all_of_with_single_ref_instance.model_dump(by_alias=True) # create an instance of AllOfWithSingleRef from a dict -all_of_with_single_ref_from_dict = AllOfWithSingleRef.from_dict(all_of_with_single_ref_dict) +all_of_with_single_ref_from_dict = AllOfWithSingleRef.model_validate(all_of_with_single_ref_dict) ``` [[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 381d27b66e44..fcded75f52be 100644 --- a/samples/openapi3/client/petstore/python/docs/Animal.md +++ b/samples/openapi3/client/petstore/python/docs/Animal.md @@ -16,14 +16,14 @@ from petstore_api.models.animal import Animal # TODO update the JSON string below json = "{}" # create an instance of Animal from a JSON string -animal_instance = Animal.from_json(json) +animal_instance = Animal.model_validate_json(json) # print the JSON string representation of the object -print(Animal.to_json()) +print(animal_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -animal_dict = animal_instance.to_dict() +animal_dict = animal_instance.model_dump(by_alias=True) # create an instance of Animal from a dict -animal_from_dict = Animal.from_dict(animal_dict) +animal_from_dict = Animal.model_validate(animal_dict) ``` [[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/AnyOfColor.md b/samples/openapi3/client/petstore/python/docs/AnyOfColor.md index 6ed75dd7b48a..02aab883b2b0 100644 --- a/samples/openapi3/client/petstore/python/docs/AnyOfColor.md +++ b/samples/openapi3/client/petstore/python/docs/AnyOfColor.md @@ -15,14 +15,14 @@ from petstore_api.models.any_of_color import AnyOfColor # TODO update the JSON string below json = "{}" # create an instance of AnyOfColor from a JSON string -any_of_color_instance = AnyOfColor.from_json(json) +any_of_color_instance = AnyOfColor.model_validate_json(json) # print the JSON string representation of the object -print(AnyOfColor.to_json()) +print(any_of_color_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -any_of_color_dict = any_of_color_instance.to_dict() +any_of_color_dict = any_of_color_instance.model_dump(by_alias=True) # create an instance of AnyOfColor from a dict -any_of_color_from_dict = AnyOfColor.from_dict(any_of_color_dict) +any_of_color_from_dict = AnyOfColor.model_validate(any_of_color_dict) ``` [[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/AnyOfPig.md b/samples/openapi3/client/petstore/python/docs/AnyOfPig.md index 9367e2261898..db2878121f29 100644 --- a/samples/openapi3/client/petstore/python/docs/AnyOfPig.md +++ b/samples/openapi3/client/petstore/python/docs/AnyOfPig.md @@ -17,14 +17,14 @@ from petstore_api.models.any_of_pig import AnyOfPig # TODO update the JSON string below json = "{}" # create an instance of AnyOfPig from a JSON string -any_of_pig_instance = AnyOfPig.from_json(json) +any_of_pig_instance = AnyOfPig.model_validate_json(json) # print the JSON string representation of the object -print(AnyOfPig.to_json()) +print(any_of_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -any_of_pig_dict = any_of_pig_instance.to_dict() +any_of_pig_dict = any_of_pig_instance.model_dump(by_alias=True) # create an instance of AnyOfPig from a dict -any_of_pig_from_dict = AnyOfPig.from_dict(any_of_pig_dict) +any_of_pig_from_dict = AnyOfPig.model_validate(any_of_pig_dict) ``` [[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/ArrayOfArrayOfModel.md b/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfModel.md index f866863d53f9..e8274d8fbb52 100644 --- a/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfModel.md +++ b/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfModel.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_array_of_model import ArrayOfArrayOfModel # TODO update the JSON string below json = "{}" # create an instance of ArrayOfArrayOfModel from a JSON string -array_of_array_of_model_instance = ArrayOfArrayOfModel.from_json(json) +array_of_array_of_model_instance = ArrayOfArrayOfModel.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfArrayOfModel.to_json()) +print(array_of_array_of_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_array_of_model_dict = array_of_array_of_model_instance.to_dict() +array_of_array_of_model_dict = array_of_array_of_model_instance.model_dump(by_alias=True) # create an instance of ArrayOfArrayOfModel from a dict -array_of_array_of_model_from_dict = ArrayOfArrayOfModel.from_dict(array_of_array_of_model_dict) +array_of_array_of_model_from_dict = ArrayOfArrayOfModel.model_validate(array_of_array_of_model_dict) ``` [[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 32bd2dfbf1e2..8931a1c7e467 100644 --- a/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumb # TODO update the JSON string below json = "{}" # create an instance of ArrayOfArrayOfNumberOnly from a JSON string -array_of_array_of_number_only_instance = ArrayOfArrayOfNumberOnly.from_json(json) +array_of_array_of_number_only_instance = ArrayOfArrayOfNumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfArrayOfNumberOnly.to_json()) +print(array_of_array_of_number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_array_of_number_only_dict = array_of_array_of_number_only_instance.to_dict() +array_of_array_of_number_only_dict = array_of_array_of_number_only_instance.model_dump(by_alias=True) # create an instance of ArrayOfArrayOfNumberOnly from a dict -array_of_array_of_number_only_from_dict = ArrayOfArrayOfNumberOnly.from_dict(array_of_array_of_number_only_dict) +array_of_array_of_number_only_from_dict = ArrayOfArrayOfNumberOnly.model_validate(array_of_array_of_number_only_dict) ``` [[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 b814d7594942..a709583be699 100644 --- a/samples/openapi3/client/petstore/python/docs/ArrayOfNumberOnly.md +++ b/samples/openapi3/client/petstore/python/docs/ArrayOfNumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.array_of_number_only import ArrayOfNumberOnly # TODO update the JSON string below json = "{}" # create an instance of ArrayOfNumberOnly from a JSON string -array_of_number_only_instance = ArrayOfNumberOnly.from_json(json) +array_of_number_only_instance = ArrayOfNumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(ArrayOfNumberOnly.to_json()) +print(array_of_number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_of_number_only_dict = array_of_number_only_instance.to_dict() +array_of_number_only_dict = array_of_number_only_instance.model_dump(by_alias=True) # create an instance of ArrayOfNumberOnly from a dict -array_of_number_only_from_dict = ArrayOfNumberOnly.from_dict(array_of_number_only_dict) +array_of_number_only_from_dict = ArrayOfNumberOnly.model_validate(array_of_number_only_dict) ``` [[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 ed871fae662d..a99eb056c5ca 100644 --- a/samples/openapi3/client/petstore/python/docs/ArrayTest.md +++ b/samples/openapi3/client/petstore/python/docs/ArrayTest.md @@ -18,14 +18,14 @@ from petstore_api.models.array_test import ArrayTest # TODO update the JSON string below json = "{}" # create an instance of ArrayTest from a JSON string -array_test_instance = ArrayTest.from_json(json) +array_test_instance = ArrayTest.model_validate_json(json) # print the JSON string representation of the object -print(ArrayTest.to_json()) +print(array_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -array_test_dict = array_test_instance.to_dict() +array_test_dict = array_test_instance.model_dump(by_alias=True) # create an instance of ArrayTest from a dict -array_test_from_dict = ArrayTest.from_dict(array_test_dict) +array_test_from_dict = ArrayTest.model_validate(array_test_dict) ``` [[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/BaseDiscriminator.md b/samples/openapi3/client/petstore/python/docs/BaseDiscriminator.md index fcdbeb032e68..0482396cbcf8 100644 --- a/samples/openapi3/client/petstore/python/docs/BaseDiscriminator.md +++ b/samples/openapi3/client/petstore/python/docs/BaseDiscriminator.md @@ -15,14 +15,14 @@ from petstore_api.models.base_discriminator import BaseDiscriminator # TODO update the JSON string below json = "{}" # create an instance of BaseDiscriminator from a JSON string -base_discriminator_instance = BaseDiscriminator.from_json(json) +base_discriminator_instance = BaseDiscriminator.model_validate_json(json) # print the JSON string representation of the object -print(BaseDiscriminator.to_json()) +print(base_discriminator_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -base_discriminator_dict = base_discriminator_instance.to_dict() +base_discriminator_dict = base_discriminator_instance.model_dump(by_alias=True) # create an instance of BaseDiscriminator from a dict -base_discriminator_from_dict = BaseDiscriminator.from_dict(base_discriminator_dict) +base_discriminator_from_dict = BaseDiscriminator.model_validate(base_discriminator_dict) ``` [[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 ee28d628722f..9844d05b3740 100644 --- a/samples/openapi3/client/petstore/python/docs/BasquePig.md +++ b/samples/openapi3/client/petstore/python/docs/BasquePig.md @@ -16,14 +16,14 @@ from petstore_api.models.basque_pig import BasquePig # TODO update the JSON string below json = "{}" # create an instance of BasquePig from a JSON string -basque_pig_instance = BasquePig.from_json(json) +basque_pig_instance = BasquePig.model_validate_json(json) # print the JSON string representation of the object -print(BasquePig.to_json()) +print(basque_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -basque_pig_dict = basque_pig_instance.to_dict() +basque_pig_dict = basque_pig_instance.model_dump(by_alias=True) # create an instance of BasquePig from a dict -basque_pig_from_dict = BasquePig.from_dict(basque_pig_dict) +basque_pig_from_dict = BasquePig.model_validate(basque_pig_dict) ``` [[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/Bathing.md b/samples/openapi3/client/petstore/python/docs/Bathing.md index 6ad70e2f67cc..2c8d8332629b 100644 --- a/samples/openapi3/client/petstore/python/docs/Bathing.md +++ b/samples/openapi3/client/petstore/python/docs/Bathing.md @@ -17,14 +17,14 @@ from petstore_api.models.bathing import Bathing # TODO update the JSON string below json = "{}" # create an instance of Bathing from a JSON string -bathing_instance = Bathing.from_json(json) +bathing_instance = Bathing.model_validate_json(json) # print the JSON string representation of the object -print(Bathing.to_json()) +print(bathing_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -bathing_dict = bathing_instance.to_dict() +bathing_dict = bathing_instance.model_dump(by_alias=True) # create an instance of Bathing from a dict -bathing_from_dict = Bathing.from_dict(bathing_dict) +bathing_from_dict = Bathing.model_validate(bathing_dict) ``` [[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 6f564a8ed8c9..55fcc0c01cb2 100644 --- a/samples/openapi3/client/petstore/python/docs/Capitalization.md +++ b/samples/openapi3/client/petstore/python/docs/Capitalization.md @@ -20,14 +20,14 @@ from petstore_api.models.capitalization import Capitalization # TODO update the JSON string below json = "{}" # create an instance of Capitalization from a JSON string -capitalization_instance = Capitalization.from_json(json) +capitalization_instance = Capitalization.model_validate_json(json) # print the JSON string representation of the object -print(Capitalization.to_json()) +print(capitalization_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -capitalization_dict = capitalization_instance.to_dict() +capitalization_dict = capitalization_instance.model_dump(by_alias=True) # create an instance of Capitalization from a dict -capitalization_from_dict = Capitalization.from_dict(capitalization_dict) +capitalization_from_dict = Capitalization.model_validate(capitalization_dict) ``` [[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/Cat.md b/samples/openapi3/client/petstore/python/docs/Cat.md index d0e39efdb33e..0845d68bd487 100644 --- a/samples/openapi3/client/petstore/python/docs/Cat.md +++ b/samples/openapi3/client/petstore/python/docs/Cat.md @@ -15,14 +15,14 @@ from petstore_api.models.cat import Cat # TODO update the JSON string below json = "{}" # create an instance of Cat from a JSON string -cat_instance = Cat.from_json(json) +cat_instance = Cat.model_validate_json(json) # print the JSON string representation of the object -print(Cat.to_json()) +print(cat_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -cat_dict = cat_instance.to_dict() +cat_dict = cat_instance.model_dump(by_alias=True) # create an instance of Cat from a dict -cat_from_dict = Cat.from_dict(cat_dict) +cat_from_dict = Cat.model_validate(cat_dict) ``` [[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 dbde14b7344c..8a14791c7925 100644 --- a/samples/openapi3/client/petstore/python/docs/Category.md +++ b/samples/openapi3/client/petstore/python/docs/Category.md @@ -16,14 +16,14 @@ from petstore_api.models.category import Category # TODO update the JSON string below json = "{}" # create an instance of Category from a JSON string -category_instance = Category.from_json(json) +category_instance = Category.model_validate_json(json) # print the JSON string representation of the object -print(Category.to_json()) +print(category_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -category_dict = category_instance.to_dict() +category_dict = category_instance.model_dump(by_alias=True) # create an instance of Category from a dict -category_from_dict = Category.from_dict(category_dict) +category_from_dict = Category.model_validate(category_dict) ``` [[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/CircularAllOfRef.md b/samples/openapi3/client/petstore/python/docs/CircularAllOfRef.md index 65b171177e58..f937a53cfe3c 100644 --- a/samples/openapi3/client/petstore/python/docs/CircularAllOfRef.md +++ b/samples/openapi3/client/petstore/python/docs/CircularAllOfRef.md @@ -16,14 +16,14 @@ from petstore_api.models.circular_all_of_ref import CircularAllOfRef # TODO update the JSON string below json = "{}" # create an instance of CircularAllOfRef from a JSON string -circular_all_of_ref_instance = CircularAllOfRef.from_json(json) +circular_all_of_ref_instance = CircularAllOfRef.model_validate_json(json) # print the JSON string representation of the object -print(CircularAllOfRef.to_json()) +print(circular_all_of_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -circular_all_of_ref_dict = circular_all_of_ref_instance.to_dict() +circular_all_of_ref_dict = circular_all_of_ref_instance.model_dump(by_alias=True) # create an instance of CircularAllOfRef from a dict -circular_all_of_ref_from_dict = CircularAllOfRef.from_dict(circular_all_of_ref_dict) +circular_all_of_ref_from_dict = CircularAllOfRef.model_validate(circular_all_of_ref_dict) ``` [[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/CircularReferenceModel.md b/samples/openapi3/client/petstore/python/docs/CircularReferenceModel.md index 87216f7273ab..9a39f46e5d7d 100644 --- a/samples/openapi3/client/petstore/python/docs/CircularReferenceModel.md +++ b/samples/openapi3/client/petstore/python/docs/CircularReferenceModel.md @@ -16,14 +16,14 @@ from petstore_api.models.circular_reference_model import CircularReferenceModel # TODO update the JSON string below json = "{}" # create an instance of CircularReferenceModel from a JSON string -circular_reference_model_instance = CircularReferenceModel.from_json(json) +circular_reference_model_instance = CircularReferenceModel.model_validate_json(json) # print the JSON string representation of the object -print(CircularReferenceModel.to_json()) +print(circular_reference_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -circular_reference_model_dict = circular_reference_model_instance.to_dict() +circular_reference_model_dict = circular_reference_model_instance.model_dump(by_alias=True) # create an instance of CircularReferenceModel from a dict -circular_reference_model_from_dict = CircularReferenceModel.from_dict(circular_reference_model_dict) +circular_reference_model_from_dict = CircularReferenceModel.model_validate(circular_reference_model_dict) ``` [[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 ea76a5c157bf..50fbfefa7661 100644 --- a/samples/openapi3/client/petstore/python/docs/ClassModel.md +++ b/samples/openapi3/client/petstore/python/docs/ClassModel.md @@ -16,14 +16,14 @@ from petstore_api.models.class_model import ClassModel # TODO update the JSON string below json = "{}" # create an instance of ClassModel from a JSON string -class_model_instance = ClassModel.from_json(json) +class_model_instance = ClassModel.model_validate_json(json) # print the JSON string representation of the object -print(ClassModel.to_json()) +print(class_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -class_model_dict = class_model_instance.to_dict() +class_model_dict = class_model_instance.model_dump(by_alias=True) # create an instance of ClassModel from a dict -class_model_from_dict = ClassModel.from_dict(class_model_dict) +class_model_from_dict = ClassModel.model_validate(class_model_dict) ``` [[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 22321c189150..160a80da457f 100644 --- a/samples/openapi3/client/petstore/python/docs/Client.md +++ b/samples/openapi3/client/petstore/python/docs/Client.md @@ -15,14 +15,14 @@ from petstore_api.models.client import Client # TODO update the JSON string below json = "{}" # create an instance of Client from a JSON string -client_instance = Client.from_json(json) +client_instance = Client.model_validate_json(json) # print the JSON string representation of the object -print(Client.to_json()) +print(client_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -client_dict = client_instance.to_dict() +client_dict = client_instance.model_dump(by_alias=True) # create an instance of Client from a dict -client_from_dict = Client.from_dict(client_dict) +client_from_dict = Client.model_validate(client_dict) ``` [[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/Color.md b/samples/openapi3/client/petstore/python/docs/Color.md index 9ac3ab2e91f4..1425ff185040 100644 --- a/samples/openapi3/client/petstore/python/docs/Color.md +++ b/samples/openapi3/client/petstore/python/docs/Color.md @@ -15,14 +15,14 @@ from petstore_api.models.color import Color # TODO update the JSON string below json = "{}" # create an instance of Color from a JSON string -color_instance = Color.from_json(json) +color_instance = Color.model_validate_json(json) # print the JSON string representation of the object -print(Color.to_json()) +print(color_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -color_dict = color_instance.to_dict() +color_dict = color_instance.model_dump(by_alias=True) # create an instance of Color from a dict -color_from_dict = Color.from_dict(color_dict) +color_from_dict = Color.model_validate(color_dict) ``` [[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/Creature.md b/samples/openapi3/client/petstore/python/docs/Creature.md index a4710214c198..eb0ba3b2f127 100644 --- a/samples/openapi3/client/petstore/python/docs/Creature.md +++ b/samples/openapi3/client/petstore/python/docs/Creature.md @@ -16,14 +16,14 @@ from petstore_api.models.creature import Creature # TODO update the JSON string below json = "{}" # create an instance of Creature from a JSON string -creature_instance = Creature.from_json(json) +creature_instance = Creature.model_validate_json(json) # print the JSON string representation of the object -print(Creature.to_json()) +print(creature_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -creature_dict = creature_instance.to_dict() +creature_dict = creature_instance.model_dump(by_alias=True) # create an instance of Creature from a dict -creature_from_dict = Creature.from_dict(creature_dict) +creature_from_dict = Creature.model_validate(creature_dict) ``` [[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/CreatureInfo.md b/samples/openapi3/client/petstore/python/docs/CreatureInfo.md index db3b82bb9ff5..156d93939201 100644 --- a/samples/openapi3/client/petstore/python/docs/CreatureInfo.md +++ b/samples/openapi3/client/petstore/python/docs/CreatureInfo.md @@ -15,14 +15,14 @@ from petstore_api.models.creature_info import CreatureInfo # TODO update the JSON string below json = "{}" # create an instance of CreatureInfo from a JSON string -creature_info_instance = CreatureInfo.from_json(json) +creature_info_instance = CreatureInfo.model_validate_json(json) # print the JSON string representation of the object -print(CreatureInfo.to_json()) +print(creature_info_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -creature_info_dict = creature_info_instance.to_dict() +creature_info_dict = creature_info_instance.model_dump(by_alias=True) # create an instance of CreatureInfo from a dict -creature_info_from_dict = CreatureInfo.from_dict(creature_info_dict) +creature_info_from_dict = CreatureInfo.model_validate(creature_info_dict) ``` [[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 16941388832a..5eac27f79e79 100644 --- a/samples/openapi3/client/petstore/python/docs/DanishPig.md +++ b/samples/openapi3/client/petstore/python/docs/DanishPig.md @@ -16,14 +16,14 @@ from petstore_api.models.danish_pig import DanishPig # TODO update the JSON string below json = "{}" # create an instance of DanishPig from a JSON string -danish_pig_instance = DanishPig.from_json(json) +danish_pig_instance = DanishPig.model_validate_json(json) # print the JSON string representation of the object -print(DanishPig.to_json()) +print(danish_pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -danish_pig_dict = danish_pig_instance.to_dict() +danish_pig_dict = danish_pig_instance.model_dump(by_alias=True) # create an instance of DanishPig from a dict -danish_pig_from_dict = DanishPig.from_dict(danish_pig_dict) +danish_pig_from_dict = DanishPig.model_validate(danish_pig_dict) ``` [[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/DeprecatedObject.md b/samples/openapi3/client/petstore/python/docs/DeprecatedObject.md index 6b362f379ba4..ff3aa9812e2d 100644 --- a/samples/openapi3/client/petstore/python/docs/DeprecatedObject.md +++ b/samples/openapi3/client/petstore/python/docs/DeprecatedObject.md @@ -15,14 +15,14 @@ from petstore_api.models.deprecated_object import DeprecatedObject # TODO update the JSON string below json = "{}" # create an instance of DeprecatedObject from a JSON string -deprecated_object_instance = DeprecatedObject.from_json(json) +deprecated_object_instance = DeprecatedObject.model_validate_json(json) # print the JSON string representation of the object -print(DeprecatedObject.to_json()) +print(deprecated_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -deprecated_object_dict = deprecated_object_instance.to_dict() +deprecated_object_dict = deprecated_object_instance.model_dump(by_alias=True) # create an instance of DeprecatedObject from a dict -deprecated_object_from_dict = DeprecatedObject.from_dict(deprecated_object_dict) +deprecated_object_from_dict = DeprecatedObject.model_validate(deprecated_object_dict) ``` [[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/DiscriminatorAllOfSub.md b/samples/openapi3/client/petstore/python/docs/DiscriminatorAllOfSub.md index f72b6e8e68ca..aa7af45b99fa 100644 --- a/samples/openapi3/client/petstore/python/docs/DiscriminatorAllOfSub.md +++ b/samples/openapi3/client/petstore/python/docs/DiscriminatorAllOfSub.md @@ -14,14 +14,14 @@ from petstore_api.models.discriminator_all_of_sub import DiscriminatorAllOfSub # TODO update the JSON string below json = "{}" # create an instance of DiscriminatorAllOfSub from a JSON string -discriminator_all_of_sub_instance = DiscriminatorAllOfSub.from_json(json) +discriminator_all_of_sub_instance = DiscriminatorAllOfSub.model_validate_json(json) # print the JSON string representation of the object -print(DiscriminatorAllOfSub.to_json()) +print(discriminator_all_of_sub_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -discriminator_all_of_sub_dict = discriminator_all_of_sub_instance.to_dict() +discriminator_all_of_sub_dict = discriminator_all_of_sub_instance.model_dump(by_alias=True) # create an instance of DiscriminatorAllOfSub from a dict -discriminator_all_of_sub_from_dict = DiscriminatorAllOfSub.from_dict(discriminator_all_of_sub_dict) +discriminator_all_of_sub_from_dict = DiscriminatorAllOfSub.model_validate(discriminator_all_of_sub_dict) ``` [[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/DiscriminatorAllOfSuper.md b/samples/openapi3/client/petstore/python/docs/DiscriminatorAllOfSuper.md index 477c05bfc446..c21e5b2296ac 100644 --- a/samples/openapi3/client/petstore/python/docs/DiscriminatorAllOfSuper.md +++ b/samples/openapi3/client/petstore/python/docs/DiscriminatorAllOfSuper.md @@ -15,14 +15,14 @@ from petstore_api.models.discriminator_all_of_super import DiscriminatorAllOfSup # TODO update the JSON string below json = "{}" # create an instance of DiscriminatorAllOfSuper from a JSON string -discriminator_all_of_super_instance = DiscriminatorAllOfSuper.from_json(json) +discriminator_all_of_super_instance = DiscriminatorAllOfSuper.model_validate_json(json) # print the JSON string representation of the object -print(DiscriminatorAllOfSuper.to_json()) +print(discriminator_all_of_super_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -discriminator_all_of_super_dict = discriminator_all_of_super_instance.to_dict() +discriminator_all_of_super_dict = discriminator_all_of_super_instance.model_dump(by_alias=True) # create an instance of DiscriminatorAllOfSuper from a dict -discriminator_all_of_super_from_dict = DiscriminatorAllOfSuper.from_dict(discriminator_all_of_super_dict) +discriminator_all_of_super_from_dict = DiscriminatorAllOfSuper.model_validate(discriminator_all_of_super_dict) ``` [[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/Dog.md b/samples/openapi3/client/petstore/python/docs/Dog.md index ed23f613d01d..2065d42f5f6b 100644 --- a/samples/openapi3/client/petstore/python/docs/Dog.md +++ b/samples/openapi3/client/petstore/python/docs/Dog.md @@ -15,14 +15,14 @@ from petstore_api.models.dog import Dog # TODO update the JSON string below json = "{}" # create an instance of Dog from a JSON string -dog_instance = Dog.from_json(json) +dog_instance = Dog.model_validate_json(json) # print the JSON string representation of the object -print(Dog.to_json()) +print(dog_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -dog_dict = dog_instance.to_dict() +dog_dict = dog_instance.model_dump(by_alias=True) # create an instance of Dog from a dict -dog_from_dict = Dog.from_dict(dog_dict) +dog_from_dict = Dog.model_validate(dog_dict) ``` [[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/DummyModel.md b/samples/openapi3/client/petstore/python/docs/DummyModel.md index 01b675977f58..dfe28d9f75b1 100644 --- a/samples/openapi3/client/petstore/python/docs/DummyModel.md +++ b/samples/openapi3/client/petstore/python/docs/DummyModel.md @@ -16,14 +16,14 @@ from petstore_api.models.dummy_model import DummyModel # TODO update the JSON string below json = "{}" # create an instance of DummyModel from a JSON string -dummy_model_instance = DummyModel.from_json(json) +dummy_model_instance = DummyModel.model_validate_json(json) # print the JSON string representation of the object -print(DummyModel.to_json()) +print(dummy_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -dummy_model_dict = dummy_model_instance.to_dict() +dummy_model_dict = dummy_model_instance.model_dump(by_alias=True) # create an instance of DummyModel from a dict -dummy_model_from_dict = DummyModel.from_dict(dummy_model_dict) +dummy_model_from_dict = DummyModel.model_validate(dummy_model_dict) ``` [[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 f44617497bce..bf8b1a6cd05c 100644 --- a/samples/openapi3/client/petstore/python/docs/EnumArrays.md +++ b/samples/openapi3/client/petstore/python/docs/EnumArrays.md @@ -16,14 +16,14 @@ from petstore_api.models.enum_arrays import EnumArrays # TODO update the JSON string below json = "{}" # create an instance of EnumArrays from a JSON string -enum_arrays_instance = EnumArrays.from_json(json) +enum_arrays_instance = EnumArrays.model_validate_json(json) # print the JSON string representation of the object -print(EnumArrays.to_json()) +print(enum_arrays_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_arrays_dict = enum_arrays_instance.to_dict() +enum_arrays_dict = enum_arrays_instance.model_dump(by_alias=True) # create an instance of EnumArrays from a dict -enum_arrays_from_dict = EnumArrays.from_dict(enum_arrays_dict) +enum_arrays_from_dict = EnumArrays.model_validate(enum_arrays_dict) ``` [[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/EnumRefWithDefaultValue.md b/samples/openapi3/client/petstore/python/docs/EnumRefWithDefaultValue.md index eeb0dc66969f..cbe6845479eb 100644 --- a/samples/openapi3/client/petstore/python/docs/EnumRefWithDefaultValue.md +++ b/samples/openapi3/client/petstore/python/docs/EnumRefWithDefaultValue.md @@ -15,14 +15,14 @@ from petstore_api.models.enum_ref_with_default_value import EnumRefWithDefaultVa # TODO update the JSON string below json = "{}" # create an instance of EnumRefWithDefaultValue from a JSON string -enum_ref_with_default_value_instance = EnumRefWithDefaultValue.from_json(json) +enum_ref_with_default_value_instance = EnumRefWithDefaultValue.model_validate_json(json) # print the JSON string representation of the object -print(EnumRefWithDefaultValue.to_json()) +print(enum_ref_with_default_value_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_ref_with_default_value_dict = enum_ref_with_default_value_instance.to_dict() +enum_ref_with_default_value_dict = enum_ref_with_default_value_instance.model_dump(by_alias=True) # create an instance of EnumRefWithDefaultValue from a dict -enum_ref_with_default_value_from_dict = EnumRefWithDefaultValue.from_dict(enum_ref_with_default_value_dict) +enum_ref_with_default_value_from_dict = EnumRefWithDefaultValue.model_validate(enum_ref_with_default_value_dict) ``` [[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 9f96c605d888..6ce4891aa9d5 100644 --- a/samples/openapi3/client/petstore/python/docs/EnumTest.md +++ b/samples/openapi3/client/petstore/python/docs/EnumTest.md @@ -27,14 +27,14 @@ from petstore_api.models.enum_test import EnumTest # TODO update the JSON string below json = "{}" # create an instance of EnumTest from a JSON string -enum_test_instance = EnumTest.from_json(json) +enum_test_instance = EnumTest.model_validate_json(json) # print the JSON string representation of the object -print(EnumTest.to_json()) +print(enum_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -enum_test_dict = enum_test_instance.to_dict() +enum_test_dict = enum_test_instance.model_dump(by_alias=True) # create an instance of EnumTest from a dict -enum_test_from_dict = EnumTest.from_dict(enum_test_dict) +enum_test_from_dict = EnumTest.model_validate(enum_test_dict) ``` [[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/Feeding.md b/samples/openapi3/client/petstore/python/docs/Feeding.md index 9f92b5d964d3..773d1373cca0 100644 --- a/samples/openapi3/client/petstore/python/docs/Feeding.md +++ b/samples/openapi3/client/petstore/python/docs/Feeding.md @@ -17,14 +17,14 @@ from petstore_api.models.feeding import Feeding # TODO update the JSON string below json = "{}" # create an instance of Feeding from a JSON string -feeding_instance = Feeding.from_json(json) +feeding_instance = Feeding.model_validate_json(json) # print the JSON string representation of the object -print(Feeding.to_json()) +print(feeding_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -feeding_dict = feeding_instance.to_dict() +feeding_dict = feeding_instance.model_dump(by_alias=True) # create an instance of Feeding from a dict -feeding_from_dict = Feeding.from_dict(feeding_dict) +feeding_from_dict = Feeding.model_validate(feeding_dict) ``` [[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 23f0567411ce..3fe748f4f30f 100644 --- a/samples/openapi3/client/petstore/python/docs/File.md +++ b/samples/openapi3/client/petstore/python/docs/File.md @@ -16,14 +16,14 @@ from petstore_api.models.file import File # TODO update the JSON string below json = "{}" # create an instance of File from a JSON string -file_instance = File.from_json(json) +file_instance = File.model_validate_json(json) # print the JSON string representation of the object -print(File.to_json()) +print(file_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -file_dict = file_instance.to_dict() +file_dict = file_instance.model_dump(by_alias=True) # create an instance of File from a dict -file_from_dict = File.from_dict(file_dict) +file_from_dict = File.model_validate(file_dict) ``` [[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 e1118042a8ec..78bc4ae135da 100644 --- a/samples/openapi3/client/petstore/python/docs/FileSchemaTestClass.md +++ b/samples/openapi3/client/petstore/python/docs/FileSchemaTestClass.md @@ -16,14 +16,14 @@ from petstore_api.models.file_schema_test_class import FileSchemaTestClass # TODO update the JSON string below json = "{}" # create an instance of FileSchemaTestClass from a JSON string -file_schema_test_class_instance = FileSchemaTestClass.from_json(json) +file_schema_test_class_instance = FileSchemaTestClass.model_validate_json(json) # print the JSON string representation of the object -print(FileSchemaTestClass.to_json()) +print(file_schema_test_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -file_schema_test_class_dict = file_schema_test_class_instance.to_dict() +file_schema_test_class_dict = file_schema_test_class_instance.model_dump(by_alias=True) # create an instance of FileSchemaTestClass from a dict -file_schema_test_class_from_dict = FileSchemaTestClass.from_dict(file_schema_test_class_dict) +file_schema_test_class_from_dict = FileSchemaTestClass.model_validate(file_schema_test_class_dict) ``` [[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/FirstRef.md b/samples/openapi3/client/petstore/python/docs/FirstRef.md index 94b8ddc5ac22..6da6650e5df7 100644 --- a/samples/openapi3/client/petstore/python/docs/FirstRef.md +++ b/samples/openapi3/client/petstore/python/docs/FirstRef.md @@ -16,14 +16,14 @@ from petstore_api.models.first_ref import FirstRef # TODO update the JSON string below json = "{}" # create an instance of FirstRef from a JSON string -first_ref_instance = FirstRef.from_json(json) +first_ref_instance = FirstRef.model_validate_json(json) # print the JSON string representation of the object -print(FirstRef.to_json()) +print(first_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -first_ref_dict = first_ref_instance.to_dict() +first_ref_dict = first_ref_instance.model_dump(by_alias=True) # create an instance of FirstRef from a dict -first_ref_from_dict = FirstRef.from_dict(first_ref_dict) +first_ref_from_dict = FirstRef.model_validate(first_ref_dict) ``` [[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 f635b0daa6db..c11ae111ee22 100644 --- a/samples/openapi3/client/petstore/python/docs/Foo.md +++ b/samples/openapi3/client/petstore/python/docs/Foo.md @@ -15,14 +15,14 @@ from petstore_api.models.foo import Foo # TODO update the JSON string below json = "{}" # create an instance of Foo from a JSON string -foo_instance = Foo.from_json(json) +foo_instance = Foo.model_validate_json(json) # print the JSON string representation of the object -print(Foo.to_json()) +print(foo_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -foo_dict = foo_instance.to_dict() +foo_dict = foo_instance.model_dump(by_alias=True) # create an instance of Foo from a dict -foo_from_dict = Foo.from_dict(foo_dict) +foo_from_dict = Foo.model_validate(foo_dict) ``` [[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/FooGetDefaultResponse.md b/samples/openapi3/client/petstore/python/docs/FooGetDefaultResponse.md index 8d84f795b00a..aaccf08bfd2e 100644 --- a/samples/openapi3/client/petstore/python/docs/FooGetDefaultResponse.md +++ b/samples/openapi3/client/petstore/python/docs/FooGetDefaultResponse.md @@ -15,14 +15,14 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse # TODO update the JSON string below json = "{}" # create an instance of FooGetDefaultResponse from a JSON string -foo_get_default_response_instance = FooGetDefaultResponse.from_json(json) +foo_get_default_response_instance = FooGetDefaultResponse.model_validate_json(json) # print the JSON string representation of the object -print(FooGetDefaultResponse.to_json()) +print(foo_get_default_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -foo_get_default_response_dict = foo_get_default_response_instance.to_dict() +foo_get_default_response_dict = foo_get_default_response_instance.model_dump(by_alias=True) # create an instance of FooGetDefaultResponse from a dict -foo_get_default_response_from_dict = FooGetDefaultResponse.from_dict(foo_get_default_response_dict) +foo_get_default_response_from_dict = FooGetDefaultResponse.model_validate(foo_get_default_response_dict) ``` [[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 714d2401bbae..98c3dc89570d 100644 --- a/samples/openapi3/client/petstore/python/docs/FormatTest.md +++ b/samples/openapi3/client/petstore/python/docs/FormatTest.md @@ -31,14 +31,14 @@ from petstore_api.models.format_test import FormatTest # TODO update the JSON string below json = "{}" # create an instance of FormatTest from a JSON string -format_test_instance = FormatTest.from_json(json) +format_test_instance = FormatTest.model_validate_json(json) # print the JSON string representation of the object -print(FormatTest.to_json()) +print(format_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -format_test_dict = format_test_instance.to_dict() +format_test_dict = format_test_instance.model_dump(by_alias=True) # create an instance of FormatTest from a dict -format_test_from_dict = FormatTest.from_dict(format_test_dict) +format_test_from_dict = FormatTest.model_validate(format_test_dict) ``` [[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 fdc48781b15a..66dca11251aa 100644 --- a/samples/openapi3/client/petstore/python/docs/HasOnlyReadOnly.md +++ b/samples/openapi3/client/petstore/python/docs/HasOnlyReadOnly.md @@ -16,14 +16,14 @@ from petstore_api.models.has_only_read_only import HasOnlyReadOnly # TODO update the JSON string below json = "{}" # create an instance of HasOnlyReadOnly from a JSON string -has_only_read_only_instance = HasOnlyReadOnly.from_json(json) +has_only_read_only_instance = HasOnlyReadOnly.model_validate_json(json) # print the JSON string representation of the object -print(HasOnlyReadOnly.to_json()) +print(has_only_read_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -has_only_read_only_dict = has_only_read_only_instance.to_dict() +has_only_read_only_dict = has_only_read_only_instance.model_dump(by_alias=True) # create an instance of HasOnlyReadOnly from a dict -has_only_read_only_from_dict = HasOnlyReadOnly.from_dict(has_only_read_only_dict) +has_only_read_only_from_dict = HasOnlyReadOnly.model_validate(has_only_read_only_dict) ``` [[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 d4a2b187167f..522156ae5b16 100644 --- a/samples/openapi3/client/petstore/python/docs/HealthCheckResult.md +++ b/samples/openapi3/client/petstore/python/docs/HealthCheckResult.md @@ -16,14 +16,14 @@ from petstore_api.models.health_check_result import HealthCheckResult # TODO update the JSON string below json = "{}" # create an instance of HealthCheckResult from a JSON string -health_check_result_instance = HealthCheckResult.from_json(json) +health_check_result_instance = HealthCheckResult.model_validate_json(json) # print the JSON string representation of the object -print(HealthCheckResult.to_json()) +print(health_check_result_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -health_check_result_dict = health_check_result_instance.to_dict() +health_check_result_dict = health_check_result_instance.model_dump(by_alias=True) # create an instance of HealthCheckResult from a dict -health_check_result_from_dict = HealthCheckResult.from_dict(health_check_result_dict) +health_check_result_from_dict = HealthCheckResult.model_validate(health_check_result_dict) ``` [[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/HuntingDog.md b/samples/openapi3/client/petstore/python/docs/HuntingDog.md index 6db6745dd022..114dfc8575d9 100644 --- a/samples/openapi3/client/petstore/python/docs/HuntingDog.md +++ b/samples/openapi3/client/petstore/python/docs/HuntingDog.md @@ -15,14 +15,14 @@ from petstore_api.models.hunting_dog import HuntingDog # TODO update the JSON string below json = "{}" # create an instance of HuntingDog from a JSON string -hunting_dog_instance = HuntingDog.from_json(json) +hunting_dog_instance = HuntingDog.model_validate_json(json) # print the JSON string representation of the object -print(HuntingDog.to_json()) +print(hunting_dog_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -hunting_dog_dict = hunting_dog_instance.to_dict() +hunting_dog_dict = hunting_dog_instance.model_dump(by_alias=True) # create an instance of HuntingDog from a dict -hunting_dog_from_dict = HuntingDog.from_dict(hunting_dog_dict) +hunting_dog_from_dict = HuntingDog.model_validate(hunting_dog_dict) ``` [[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/Info.md b/samples/openapi3/client/petstore/python/docs/Info.md index db88778a9143..160c3633247c 100644 --- a/samples/openapi3/client/petstore/python/docs/Info.md +++ b/samples/openapi3/client/petstore/python/docs/Info.md @@ -15,14 +15,14 @@ from petstore_api.models.info import Info # TODO update the JSON string below json = "{}" # create an instance of Info from a JSON string -info_instance = Info.from_json(json) +info_instance = Info.model_validate_json(json) # print the JSON string representation of the object -print(Info.to_json()) +print(info_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -info_dict = info_instance.to_dict() +info_dict = info_instance.model_dump(by_alias=True) # create an instance of Info from a dict -info_from_dict = Info.from_dict(info_dict) +info_from_dict = Info.model_validate(info_dict) ``` [[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/InnerDictWithProperty.md b/samples/openapi3/client/petstore/python/docs/InnerDictWithProperty.md index 7b82ebb770b8..79234d754027 100644 --- a/samples/openapi3/client/petstore/python/docs/InnerDictWithProperty.md +++ b/samples/openapi3/client/petstore/python/docs/InnerDictWithProperty.md @@ -15,14 +15,14 @@ from petstore_api.models.inner_dict_with_property import InnerDictWithProperty # TODO update the JSON string below json = "{}" # create an instance of InnerDictWithProperty from a JSON string -inner_dict_with_property_instance = InnerDictWithProperty.from_json(json) +inner_dict_with_property_instance = InnerDictWithProperty.model_validate_json(json) # print the JSON string representation of the object -print(InnerDictWithProperty.to_json()) +print(inner_dict_with_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -inner_dict_with_property_dict = inner_dict_with_property_instance.to_dict() +inner_dict_with_property_dict = inner_dict_with_property_instance.model_dump(by_alias=True) # create an instance of InnerDictWithProperty from a dict -inner_dict_with_property_from_dict = InnerDictWithProperty.from_dict(inner_dict_with_property_dict) +inner_dict_with_property_from_dict = InnerDictWithProperty.model_validate(inner_dict_with_property_dict) ``` [[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/InputAllOf.md b/samples/openapi3/client/petstore/python/docs/InputAllOf.md index 45298f5308fc..32d4100ac9de 100644 --- a/samples/openapi3/client/petstore/python/docs/InputAllOf.md +++ b/samples/openapi3/client/petstore/python/docs/InputAllOf.md @@ -15,14 +15,14 @@ from petstore_api.models.input_all_of import InputAllOf # TODO update the JSON string below json = "{}" # create an instance of InputAllOf from a JSON string -input_all_of_instance = InputAllOf.from_json(json) +input_all_of_instance = InputAllOf.model_validate_json(json) # print the JSON string representation of the object -print(InputAllOf.to_json()) +print(input_all_of_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -input_all_of_dict = input_all_of_instance.to_dict() +input_all_of_dict = input_all_of_instance.model_dump(by_alias=True) # create an instance of InputAllOf from a dict -input_all_of_from_dict = InputAllOf.from_dict(input_all_of_dict) +input_all_of_from_dict = InputAllOf.model_validate(input_all_of_dict) ``` [[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/IntOrString.md b/samples/openapi3/client/petstore/python/docs/IntOrString.md index b4070b9a8c79..ea8e06339493 100644 --- a/samples/openapi3/client/petstore/python/docs/IntOrString.md +++ b/samples/openapi3/client/petstore/python/docs/IntOrString.md @@ -14,14 +14,14 @@ from petstore_api.models.int_or_string import IntOrString # TODO update the JSON string below json = "{}" # create an instance of IntOrString from a JSON string -int_or_string_instance = IntOrString.from_json(json) +int_or_string_instance = IntOrString.model_validate_json(json) # print the JSON string representation of the object -print(IntOrString.to_json()) +print(int_or_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -int_or_string_dict = int_or_string_instance.to_dict() +int_or_string_dict = int_or_string_instance.model_dump(by_alias=True) # create an instance of IntOrString from a dict -int_or_string_from_dict = IntOrString.from_dict(int_or_string_dict) +int_or_string_from_dict = IntOrString.model_validate(int_or_string_dict) ``` [[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/ListClass.md b/samples/openapi3/client/petstore/python/docs/ListClass.md index 01068b7d22c3..8bc905105efe 100644 --- a/samples/openapi3/client/petstore/python/docs/ListClass.md +++ b/samples/openapi3/client/petstore/python/docs/ListClass.md @@ -15,14 +15,14 @@ from petstore_api.models.list_class import ListClass # TODO update the JSON string below json = "{}" # create an instance of ListClass from a JSON string -list_class_instance = ListClass.from_json(json) +list_class_instance = ListClass.model_validate_json(json) # print the JSON string representation of the object -print(ListClass.to_json()) +print(list_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -list_class_dict = list_class_instance.to_dict() +list_class_dict = list_class_instance.model_dump(by_alias=True) # create an instance of ListClass from a dict -list_class_from_dict = ListClass.from_dict(list_class_dict) +list_class_from_dict = ListClass.model_validate(list_class_dict) ``` [[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/MapOfArrayOfModel.md b/samples/openapi3/client/petstore/python/docs/MapOfArrayOfModel.md index 71a4ef66b682..acea13d9a9f5 100644 --- a/samples/openapi3/client/petstore/python/docs/MapOfArrayOfModel.md +++ b/samples/openapi3/client/petstore/python/docs/MapOfArrayOfModel.md @@ -15,14 +15,14 @@ from petstore_api.models.map_of_array_of_model import MapOfArrayOfModel # TODO update the JSON string below json = "{}" # create an instance of MapOfArrayOfModel from a JSON string -map_of_array_of_model_instance = MapOfArrayOfModel.from_json(json) +map_of_array_of_model_instance = MapOfArrayOfModel.model_validate_json(json) # print the JSON string representation of the object -print(MapOfArrayOfModel.to_json()) +print(map_of_array_of_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -map_of_array_of_model_dict = map_of_array_of_model_instance.to_dict() +map_of_array_of_model_dict = map_of_array_of_model_instance.model_dump(by_alias=True) # create an instance of MapOfArrayOfModel from a dict -map_of_array_of_model_from_dict = MapOfArrayOfModel.from_dict(map_of_array_of_model_dict) +map_of_array_of_model_from_dict = MapOfArrayOfModel.model_validate(map_of_array_of_model_dict) ``` [[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 d04b82e9378c..fa4501d24286 100644 --- a/samples/openapi3/client/petstore/python/docs/MapTest.md +++ b/samples/openapi3/client/petstore/python/docs/MapTest.md @@ -18,14 +18,14 @@ from petstore_api.models.map_test import MapTest # TODO update the JSON string below json = "{}" # create an instance of MapTest from a JSON string -map_test_instance = MapTest.from_json(json) +map_test_instance = MapTest.model_validate_json(json) # print the JSON string representation of the object -print(MapTest.to_json()) +print(map_test_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -map_test_dict = map_test_instance.to_dict() +map_test_dict = map_test_instance.model_dump(by_alias=True) # create an instance of MapTest from a dict -map_test_from_dict = MapTest.from_dict(map_test_dict) +map_test_from_dict = MapTest.model_validate(map_test_dict) ``` [[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 84134317aefc..fb354956720a 100644 --- a/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -17,14 +17,14 @@ from petstore_api.models.mixed_properties_and_additional_properties_class import # TODO update the JSON string below json = "{}" # create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string -mixed_properties_and_additional_properties_class_instance = MixedPropertiesAndAdditionalPropertiesClass.from_json(json) +mixed_properties_and_additional_properties_class_instance = MixedPropertiesAndAdditionalPropertiesClass.model_validate_json(json) # print the JSON string representation of the object -print(MixedPropertiesAndAdditionalPropertiesClass.to_json()) +print(mixed_properties_and_additional_properties_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -mixed_properties_and_additional_properties_class_dict = mixed_properties_and_additional_properties_class_instance.to_dict() +mixed_properties_and_additional_properties_class_dict = mixed_properties_and_additional_properties_class_instance.model_dump(by_alias=True) # create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict -mixed_properties_and_additional_properties_class_from_dict = MixedPropertiesAndAdditionalPropertiesClass.from_dict(mixed_properties_and_additional_properties_class_dict) +mixed_properties_and_additional_properties_class_from_dict = MixedPropertiesAndAdditionalPropertiesClass.model_validate(mixed_properties_and_additional_properties_class_dict) ``` [[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 7fdbdefc6cec..6cffad7a6d3a 100644 --- a/samples/openapi3/client/petstore/python/docs/Model200Response.md +++ b/samples/openapi3/client/petstore/python/docs/Model200Response.md @@ -17,14 +17,14 @@ from petstore_api.models.model200_response import Model200Response # TODO update the JSON string below json = "{}" # create an instance of Model200Response from a JSON string -model200_response_instance = Model200Response.from_json(json) +model200_response_instance = Model200Response.model_validate_json(json) # print the JSON string representation of the object -print(Model200Response.to_json()) +print(model200_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model200_response_dict = model200_response_instance.to_dict() +model200_response_dict = model200_response_instance.model_dump(by_alias=True) # create an instance of Model200Response from a dict -model200_response_from_dict = Model200Response.from_dict(model200_response_dict) +model200_response_from_dict = Model200Response.model_validate(model200_response_dict) ``` [[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/ModelApiResponse.md b/samples/openapi3/client/petstore/python/docs/ModelApiResponse.md index 5ddc0db2a0f3..4fdaa910bce4 100644 --- a/samples/openapi3/client/petstore/python/docs/ModelApiResponse.md +++ b/samples/openapi3/client/petstore/python/docs/ModelApiResponse.md @@ -17,14 +17,14 @@ from petstore_api.models.model_api_response import ModelApiResponse # TODO update the JSON string below json = "{}" # create an instance of ModelApiResponse from a JSON string -model_api_response_instance = ModelApiResponse.from_json(json) +model_api_response_instance = ModelApiResponse.model_validate_json(json) # print the JSON string representation of the object -print(ModelApiResponse.to_json()) +print(model_api_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_api_response_dict = model_api_response_instance.to_dict() +model_api_response_dict = model_api_response_instance.model_dump(by_alias=True) # create an instance of ModelApiResponse from a dict -model_api_response_from_dict = ModelApiResponse.from_dict(model_api_response_dict) +model_api_response_from_dict = ModelApiResponse.model_validate(model_api_response_dict) ``` [[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/ModelField.md b/samples/openapi3/client/petstore/python/docs/ModelField.md index 9073b5dbdb00..43f064bd85a4 100644 --- a/samples/openapi3/client/petstore/python/docs/ModelField.md +++ b/samples/openapi3/client/petstore/python/docs/ModelField.md @@ -15,14 +15,14 @@ from petstore_api.models.model_field import ModelField # TODO update the JSON string below json = "{}" # create an instance of ModelField from a JSON string -model_field_instance = ModelField.from_json(json) +model_field_instance = ModelField.model_validate_json(json) # print the JSON string representation of the object -print(ModelField.to_json()) +print(model_field_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_field_dict = model_field_instance.to_dict() +model_field_dict = model_field_instance.model_dump(by_alias=True) # create an instance of ModelField from a dict -model_field_from_dict = ModelField.from_dict(model_field_dict) +model_field_from_dict = ModelField.model_validate(model_field_dict) ``` [[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 7d327053b0c3..236b2bb971ee 100644 --- a/samples/openapi3/client/petstore/python/docs/ModelReturn.md +++ b/samples/openapi3/client/petstore/python/docs/ModelReturn.md @@ -16,14 +16,14 @@ from petstore_api.models.model_return import ModelReturn # TODO update the JSON string below json = "{}" # create an instance of ModelReturn from a JSON string -model_return_instance = ModelReturn.from_json(json) +model_return_instance = ModelReturn.model_validate_json(json) # print the JSON string representation of the object -print(ModelReturn.to_json()) +print(model_return_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -model_return_dict = model_return_instance.to_dict() +model_return_dict = model_return_instance.model_dump(by_alias=True) # create an instance of ModelReturn from a dict -model_return_from_dict = ModelReturn.from_dict(model_return_dict) +model_return_from_dict = ModelReturn.model_validate(model_return_dict) ``` [[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/MultiArrays.md b/samples/openapi3/client/petstore/python/docs/MultiArrays.md index fea5139e7e73..9cf5c5bb1faa 100644 --- a/samples/openapi3/client/petstore/python/docs/MultiArrays.md +++ b/samples/openapi3/client/petstore/python/docs/MultiArrays.md @@ -16,14 +16,14 @@ from petstore_api.models.multi_arrays import MultiArrays # TODO update the JSON string below json = "{}" # create an instance of MultiArrays from a JSON string -multi_arrays_instance = MultiArrays.from_json(json) +multi_arrays_instance = MultiArrays.model_validate_json(json) # print the JSON string representation of the object -print(MultiArrays.to_json()) +print(multi_arrays_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -multi_arrays_dict = multi_arrays_instance.to_dict() +multi_arrays_dict = multi_arrays_instance.model_dump(by_alias=True) # create an instance of MultiArrays from a dict -multi_arrays_from_dict = MultiArrays.from_dict(multi_arrays_dict) +multi_arrays_from_dict = MultiArrays.model_validate(multi_arrays_dict) ``` [[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 5a04ec1ada06..f9d2da4cccd2 100644 --- a/samples/openapi3/client/petstore/python/docs/Name.md +++ b/samples/openapi3/client/petstore/python/docs/Name.md @@ -19,14 +19,14 @@ from petstore_api.models.name import Name # TODO update the JSON string below json = "{}" # create an instance of Name from a JSON string -name_instance = Name.from_json(json) +name_instance = Name.model_validate_json(json) # print the JSON string representation of the object -print(Name.to_json()) +print(name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -name_dict = name_instance.to_dict() +name_dict = name_instance.model_dump(by_alias=True) # create an instance of Name from a dict -name_from_dict = Name.from_dict(name_dict) +name_from_dict = Name.model_validate(name_dict) ``` [[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 0387dcc2c67a..cd84aa96eb19 100644 --- a/samples/openapi3/client/petstore/python/docs/NullableClass.md +++ b/samples/openapi3/client/petstore/python/docs/NullableClass.md @@ -27,14 +27,14 @@ from petstore_api.models.nullable_class import NullableClass # TODO update the JSON string below json = "{}" # create an instance of NullableClass from a JSON string -nullable_class_instance = NullableClass.from_json(json) +nullable_class_instance = NullableClass.model_validate_json(json) # print the JSON string representation of the object -print(NullableClass.to_json()) +print(nullable_class_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -nullable_class_dict = nullable_class_instance.to_dict() +nullable_class_dict = nullable_class_instance.model_dump(by_alias=True) # create an instance of NullableClass from a dict -nullable_class_from_dict = NullableClass.from_dict(nullable_class_dict) +nullable_class_from_dict = NullableClass.model_validate(nullable_class_dict) ``` [[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/NullableProperty.md b/samples/openapi3/client/petstore/python/docs/NullableProperty.md index 30edaf4844b2..c0ef9b80fcb5 100644 --- a/samples/openapi3/client/petstore/python/docs/NullableProperty.md +++ b/samples/openapi3/client/petstore/python/docs/NullableProperty.md @@ -16,14 +16,14 @@ from petstore_api.models.nullable_property import NullableProperty # TODO update the JSON string below json = "{}" # create an instance of NullableProperty from a JSON string -nullable_property_instance = NullableProperty.from_json(json) +nullable_property_instance = NullableProperty.model_validate_json(json) # print the JSON string representation of the object -print(NullableProperty.to_json()) +print(nullable_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -nullable_property_dict = nullable_property_instance.to_dict() +nullable_property_dict = nullable_property_instance.model_dump(by_alias=True) # create an instance of NullableProperty from a dict -nullable_property_from_dict = NullableProperty.from_dict(nullable_property_dict) +nullable_property_from_dict = NullableProperty.model_validate(nullable_property_dict) ``` [[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 415dd25585d4..f1caf70ea2b7 100644 --- a/samples/openapi3/client/petstore/python/docs/NumberOnly.md +++ b/samples/openapi3/client/petstore/python/docs/NumberOnly.md @@ -15,14 +15,14 @@ from petstore_api.models.number_only import NumberOnly # TODO update the JSON string below json = "{}" # create an instance of NumberOnly from a JSON string -number_only_instance = NumberOnly.from_json(json) +number_only_instance = NumberOnly.model_validate_json(json) # print the JSON string representation of the object -print(NumberOnly.to_json()) +print(number_only_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -number_only_dict = number_only_instance.to_dict() +number_only_dict = number_only_instance.model_dump(by_alias=True) # create an instance of NumberOnly from a dict -number_only_from_dict = NumberOnly.from_dict(number_only_dict) +number_only_from_dict = NumberOnly.model_validate(number_only_dict) ``` [[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/ObjectToTestAdditionalProperties.md b/samples/openapi3/client/petstore/python/docs/ObjectToTestAdditionalProperties.md index f6bc34c98e65..f201a9627dc3 100644 --- a/samples/openapi3/client/petstore/python/docs/ObjectToTestAdditionalProperties.md +++ b/samples/openapi3/client/petstore/python/docs/ObjectToTestAdditionalProperties.md @@ -16,14 +16,14 @@ from petstore_api.models.object_to_test_additional_properties import ObjectToTes # TODO update the JSON string below json = "{}" # create an instance of ObjectToTestAdditionalProperties from a JSON string -object_to_test_additional_properties_instance = ObjectToTestAdditionalProperties.from_json(json) +object_to_test_additional_properties_instance = ObjectToTestAdditionalProperties.model_validate_json(json) # print the JSON string representation of the object -print(ObjectToTestAdditionalProperties.to_json()) +print(object_to_test_additional_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -object_to_test_additional_properties_dict = object_to_test_additional_properties_instance.to_dict() +object_to_test_additional_properties_dict = object_to_test_additional_properties_instance.model_dump(by_alias=True) # create an instance of ObjectToTestAdditionalProperties from a dict -object_to_test_additional_properties_from_dict = ObjectToTestAdditionalProperties.from_dict(object_to_test_additional_properties_dict) +object_to_test_additional_properties_from_dict = ObjectToTestAdditionalProperties.model_validate(object_to_test_additional_properties_dict) ``` [[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/ObjectWithDeprecatedFields.md b/samples/openapi3/client/petstore/python/docs/ObjectWithDeprecatedFields.md index 6dbd2ace04f1..86cce93ba775 100644 --- a/samples/openapi3/client/petstore/python/docs/ObjectWithDeprecatedFields.md +++ b/samples/openapi3/client/petstore/python/docs/ObjectWithDeprecatedFields.md @@ -18,14 +18,14 @@ from petstore_api.models.object_with_deprecated_fields import ObjectWithDeprecat # TODO update the JSON string below json = "{}" # create an instance of ObjectWithDeprecatedFields from a JSON string -object_with_deprecated_fields_instance = ObjectWithDeprecatedFields.from_json(json) +object_with_deprecated_fields_instance = ObjectWithDeprecatedFields.model_validate_json(json) # print the JSON string representation of the object -print(ObjectWithDeprecatedFields.to_json()) +print(object_with_deprecated_fields_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -object_with_deprecated_fields_dict = object_with_deprecated_fields_instance.to_dict() +object_with_deprecated_fields_dict = object_with_deprecated_fields_instance.model_dump(by_alias=True) # create an instance of ObjectWithDeprecatedFields from a dict -object_with_deprecated_fields_from_dict = ObjectWithDeprecatedFields.from_dict(object_with_deprecated_fields_dict) +object_with_deprecated_fields_from_dict = ObjectWithDeprecatedFields.model_validate(object_with_deprecated_fields_dict) ``` [[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/OneOfEnumString.md b/samples/openapi3/client/petstore/python/docs/OneOfEnumString.md index 1d385c092934..69f4f99d32e4 100644 --- a/samples/openapi3/client/petstore/python/docs/OneOfEnumString.md +++ b/samples/openapi3/client/petstore/python/docs/OneOfEnumString.md @@ -15,14 +15,14 @@ from petstore_api.models.one_of_enum_string import OneOfEnumString # TODO update the JSON string below json = "{}" # create an instance of OneOfEnumString from a JSON string -one_of_enum_string_instance = OneOfEnumString.from_json(json) +one_of_enum_string_instance = OneOfEnumString.model_validate_json(json) # print the JSON string representation of the object -print(OneOfEnumString.to_json()) +print(one_of_enum_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -one_of_enum_string_dict = one_of_enum_string_instance.to_dict() +one_of_enum_string_dict = one_of_enum_string_instance.model_dump(by_alias=True) # create an instance of OneOfEnumString from a dict -one_of_enum_string_from_dict = OneOfEnumString.from_dict(one_of_enum_string_dict) +one_of_enum_string_from_dict = OneOfEnumString.model_validate(one_of_enum_string_dict) ``` [[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 00526b8d04b9..f5410bc8d0f3 100644 --- a/samples/openapi3/client/petstore/python/docs/Order.md +++ b/samples/openapi3/client/petstore/python/docs/Order.md @@ -20,14 +20,14 @@ from petstore_api.models.order import Order # TODO update the JSON string below json = "{}" # create an instance of Order from a JSON string -order_instance = Order.from_json(json) +order_instance = Order.model_validate_json(json) # print the JSON string representation of the object -print(Order.to_json()) +print(order_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -order_dict = order_instance.to_dict() +order_dict = order_instance.model_dump(by_alias=True) # create an instance of Order from a dict -order_from_dict = Order.from_dict(order_dict) +order_from_dict = Order.model_validate(order_dict) ``` [[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/OuterComposite.md b/samples/openapi3/client/petstore/python/docs/OuterComposite.md index c8242c2d2653..9df82e2abc87 100644 --- a/samples/openapi3/client/petstore/python/docs/OuterComposite.md +++ b/samples/openapi3/client/petstore/python/docs/OuterComposite.md @@ -17,14 +17,14 @@ from petstore_api.models.outer_composite import OuterComposite # TODO update the JSON string below json = "{}" # create an instance of OuterComposite from a JSON string -outer_composite_instance = OuterComposite.from_json(json) +outer_composite_instance = OuterComposite.model_validate_json(json) # print the JSON string representation of the object -print(OuterComposite.to_json()) +print(outer_composite_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -outer_composite_dict = outer_composite_instance.to_dict() +outer_composite_dict = outer_composite_instance.model_dump(by_alias=True) # create an instance of OuterComposite from a dict -outer_composite_from_dict = OuterComposite.from_dict(outer_composite_dict) +outer_composite_from_dict = OuterComposite.model_validate(outer_composite_dict) ``` [[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/OuterObjectWithEnumProperty.md b/samples/openapi3/client/petstore/python/docs/OuterObjectWithEnumProperty.md index 6137dbd98da6..d23ccc3757bb 100644 --- a/samples/openapi3/client/petstore/python/docs/OuterObjectWithEnumProperty.md +++ b/samples/openapi3/client/petstore/python/docs/OuterObjectWithEnumProperty.md @@ -16,14 +16,14 @@ from petstore_api.models.outer_object_with_enum_property import OuterObjectWithE # TODO update the JSON string below json = "{}" # create an instance of OuterObjectWithEnumProperty from a JSON string -outer_object_with_enum_property_instance = OuterObjectWithEnumProperty.from_json(json) +outer_object_with_enum_property_instance = OuterObjectWithEnumProperty.model_validate_json(json) # print the JSON string representation of the object -print(OuterObjectWithEnumProperty.to_json()) +print(outer_object_with_enum_property_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -outer_object_with_enum_property_dict = outer_object_with_enum_property_instance.to_dict() +outer_object_with_enum_property_dict = outer_object_with_enum_property_instance.model_dump(by_alias=True) # create an instance of OuterObjectWithEnumProperty from a dict -outer_object_with_enum_property_from_dict = OuterObjectWithEnumProperty.from_dict(outer_object_with_enum_property_dict) +outer_object_with_enum_property_from_dict = OuterObjectWithEnumProperty.model_validate(outer_object_with_enum_property_dict) ``` [[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/Parent.md b/samples/openapi3/client/petstore/python/docs/Parent.md index 7387f9250aad..21df089ea756 100644 --- a/samples/openapi3/client/petstore/python/docs/Parent.md +++ b/samples/openapi3/client/petstore/python/docs/Parent.md @@ -15,14 +15,14 @@ from petstore_api.models.parent import Parent # TODO update the JSON string below json = "{}" # create an instance of Parent from a JSON string -parent_instance = Parent.from_json(json) +parent_instance = Parent.model_validate_json(json) # print the JSON string representation of the object -print(Parent.to_json()) +print(parent_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -parent_dict = parent_instance.to_dict() +parent_dict = parent_instance.model_dump(by_alias=True) # create an instance of Parent from a dict -parent_from_dict = Parent.from_dict(parent_dict) +parent_from_dict = Parent.model_validate(parent_dict) ``` [[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/ParentWithOptionalDict.md b/samples/openapi3/client/petstore/python/docs/ParentWithOptionalDict.md index bfc8688ea26f..a6ee19fd1a74 100644 --- a/samples/openapi3/client/petstore/python/docs/ParentWithOptionalDict.md +++ b/samples/openapi3/client/petstore/python/docs/ParentWithOptionalDict.md @@ -15,14 +15,14 @@ from petstore_api.models.parent_with_optional_dict import ParentWithOptionalDict # TODO update the JSON string below json = "{}" # create an instance of ParentWithOptionalDict from a JSON string -parent_with_optional_dict_instance = ParentWithOptionalDict.from_json(json) +parent_with_optional_dict_instance = ParentWithOptionalDict.model_validate_json(json) # print the JSON string representation of the object -print(ParentWithOptionalDict.to_json()) +print(parent_with_optional_dict_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -parent_with_optional_dict_dict = parent_with_optional_dict_instance.to_dict() +parent_with_optional_dict_dict = parent_with_optional_dict_instance.model_dump(by_alias=True) # create an instance of ParentWithOptionalDict from a dict -parent_with_optional_dict_from_dict = ParentWithOptionalDict.from_dict(parent_with_optional_dict_dict) +parent_with_optional_dict_from_dict = ParentWithOptionalDict.model_validate(parent_with_optional_dict_dict) ``` [[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 5329cf2fb925..179b71891d9d 100644 --- a/samples/openapi3/client/petstore/python/docs/Pet.md +++ b/samples/openapi3/client/petstore/python/docs/Pet.md @@ -20,14 +20,14 @@ from petstore_api.models.pet import Pet # TODO update the JSON string below json = "{}" # create an instance of Pet from a JSON string -pet_instance = Pet.from_json(json) +pet_instance = Pet.model_validate_json(json) # print the JSON string representation of the object -print(Pet.to_json()) +print(pet_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pet_dict = pet_instance.to_dict() +pet_dict = pet_instance.model_dump(by_alias=True) # create an instance of Pet from a dict -pet_from_dict = Pet.from_dict(pet_dict) +pet_from_dict = Pet.model_validate(pet_dict) ``` [[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/Pig.md b/samples/openapi3/client/petstore/python/docs/Pig.md index 625930676083..2e275198c547 100644 --- a/samples/openapi3/client/petstore/python/docs/Pig.md +++ b/samples/openapi3/client/petstore/python/docs/Pig.md @@ -17,14 +17,14 @@ from petstore_api.models.pig import Pig # TODO update the JSON string below json = "{}" # create an instance of Pig from a JSON string -pig_instance = Pig.from_json(json) +pig_instance = Pig.model_validate_json(json) # print the JSON string representation of the object -print(Pig.to_json()) +print(pig_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pig_dict = pig_instance.to_dict() +pig_dict = pig_instance.model_dump(by_alias=True) # create an instance of Pig from a dict -pig_from_dict = Pig.from_dict(pig_dict) +pig_from_dict = Pig.model_validate(pig_dict) ``` [[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/PonySizes.md b/samples/openapi3/client/petstore/python/docs/PonySizes.md index ced44c872060..6bb28b418b6d 100644 --- a/samples/openapi3/client/petstore/python/docs/PonySizes.md +++ b/samples/openapi3/client/petstore/python/docs/PonySizes.md @@ -15,14 +15,14 @@ from petstore_api.models.pony_sizes import PonySizes # TODO update the JSON string below json = "{}" # create an instance of PonySizes from a JSON string -pony_sizes_instance = PonySizes.from_json(json) +pony_sizes_instance = PonySizes.model_validate_json(json) # print the JSON string representation of the object -print(PonySizes.to_json()) +print(pony_sizes_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -pony_sizes_dict = pony_sizes_instance.to_dict() +pony_sizes_dict = pony_sizes_instance.model_dump(by_alias=True) # create an instance of PonySizes from a dict -pony_sizes_from_dict = PonySizes.from_dict(pony_sizes_dict) +pony_sizes_from_dict = PonySizes.model_validate(pony_sizes_dict) ``` [[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/PoopCleaning.md b/samples/openapi3/client/petstore/python/docs/PoopCleaning.md index 8f9c25e08316..3bf20593f929 100644 --- a/samples/openapi3/client/petstore/python/docs/PoopCleaning.md +++ b/samples/openapi3/client/petstore/python/docs/PoopCleaning.md @@ -17,14 +17,14 @@ from petstore_api.models.poop_cleaning import PoopCleaning # TODO update the JSON string below json = "{}" # create an instance of PoopCleaning from a JSON string -poop_cleaning_instance = PoopCleaning.from_json(json) +poop_cleaning_instance = PoopCleaning.model_validate_json(json) # print the JSON string representation of the object -print(PoopCleaning.to_json()) +print(poop_cleaning_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -poop_cleaning_dict = poop_cleaning_instance.to_dict() +poop_cleaning_dict = poop_cleaning_instance.model_dump(by_alias=True) # create an instance of PoopCleaning from a dict -poop_cleaning_from_dict = PoopCleaning.from_dict(poop_cleaning_dict) +poop_cleaning_from_dict = PoopCleaning.model_validate(poop_cleaning_dict) ``` [[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/PrimitiveString.md b/samples/openapi3/client/petstore/python/docs/PrimitiveString.md index 85ceb632e167..a1a9a3dc81b6 100644 --- a/samples/openapi3/client/petstore/python/docs/PrimitiveString.md +++ b/samples/openapi3/client/petstore/python/docs/PrimitiveString.md @@ -15,14 +15,14 @@ from petstore_api.models.primitive_string import PrimitiveString # TODO update the JSON string below json = "{}" # create an instance of PrimitiveString from a JSON string -primitive_string_instance = PrimitiveString.from_json(json) +primitive_string_instance = PrimitiveString.model_validate_json(json) # print the JSON string representation of the object -print(PrimitiveString.to_json()) +print(primitive_string_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -primitive_string_dict = primitive_string_instance.to_dict() +primitive_string_dict = primitive_string_instance.model_dump(by_alias=True) # create an instance of PrimitiveString from a dict -primitive_string_from_dict = PrimitiveString.from_dict(primitive_string_dict) +primitive_string_from_dict = PrimitiveString.model_validate(primitive_string_dict) ``` [[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/PropertyMap.md b/samples/openapi3/client/petstore/python/docs/PropertyMap.md index a55a0e5c6f01..5fcda1f7803d 100644 --- a/samples/openapi3/client/petstore/python/docs/PropertyMap.md +++ b/samples/openapi3/client/petstore/python/docs/PropertyMap.md @@ -15,14 +15,14 @@ from petstore_api.models.property_map import PropertyMap # TODO update the JSON string below json = "{}" # create an instance of PropertyMap from a JSON string -property_map_instance = PropertyMap.from_json(json) +property_map_instance = PropertyMap.model_validate_json(json) # print the JSON string representation of the object -print(PropertyMap.to_json()) +print(property_map_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -property_map_dict = property_map_instance.to_dict() +property_map_dict = property_map_instance.model_dump(by_alias=True) # create an instance of PropertyMap from a dict -property_map_from_dict = PropertyMap.from_dict(property_map_dict) +property_map_from_dict = PropertyMap.model_validate(property_map_dict) ``` [[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/PropertyNameCollision.md b/samples/openapi3/client/petstore/python/docs/PropertyNameCollision.md index 40c233670dd0..a4a8405fe847 100644 --- a/samples/openapi3/client/petstore/python/docs/PropertyNameCollision.md +++ b/samples/openapi3/client/petstore/python/docs/PropertyNameCollision.md @@ -17,14 +17,14 @@ from petstore_api.models.property_name_collision import PropertyNameCollision # TODO update the JSON string below json = "{}" # create an instance of PropertyNameCollision from a JSON string -property_name_collision_instance = PropertyNameCollision.from_json(json) +property_name_collision_instance = PropertyNameCollision.model_validate_json(json) # print the JSON string representation of the object -print(PropertyNameCollision.to_json()) +print(property_name_collision_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -property_name_collision_dict = property_name_collision_instance.to_dict() +property_name_collision_dict = property_name_collision_instance.model_dump(by_alias=True) # create an instance of PropertyNameCollision from a dict -property_name_collision_from_dict = PropertyNameCollision.from_dict(property_name_collision_dict) +property_name_collision_from_dict = PropertyNameCollision.model_validate(property_name_collision_dict) ``` [[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 686ec5da41c9..e55fe102b673 100644 --- a/samples/openapi3/client/petstore/python/docs/ReadOnlyFirst.md +++ b/samples/openapi3/client/petstore/python/docs/ReadOnlyFirst.md @@ -16,14 +16,14 @@ from petstore_api.models.read_only_first import ReadOnlyFirst # TODO update the JSON string below json = "{}" # create an instance of ReadOnlyFirst from a JSON string -read_only_first_instance = ReadOnlyFirst.from_json(json) +read_only_first_instance = ReadOnlyFirst.model_validate_json(json) # print the JSON string representation of the object -print(ReadOnlyFirst.to_json()) +print(read_only_first_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -read_only_first_dict = read_only_first_instance.to_dict() +read_only_first_dict = read_only_first_instance.model_dump(by_alias=True) # create an instance of ReadOnlyFirst from a dict -read_only_first_from_dict = ReadOnlyFirst.from_dict(read_only_first_dict) +read_only_first_from_dict = ReadOnlyFirst.model_validate(read_only_first_dict) ``` [[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/SecondCircularAllOfRef.md b/samples/openapi3/client/petstore/python/docs/SecondCircularAllOfRef.md index 65ebdd4c7e1d..47fb4daf97a4 100644 --- a/samples/openapi3/client/petstore/python/docs/SecondCircularAllOfRef.md +++ b/samples/openapi3/client/petstore/python/docs/SecondCircularAllOfRef.md @@ -16,14 +16,14 @@ from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRe # TODO update the JSON string below json = "{}" # create an instance of SecondCircularAllOfRef from a JSON string -second_circular_all_of_ref_instance = SecondCircularAllOfRef.from_json(json) +second_circular_all_of_ref_instance = SecondCircularAllOfRef.model_validate_json(json) # print the JSON string representation of the object -print(SecondCircularAllOfRef.to_json()) +print(second_circular_all_of_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -second_circular_all_of_ref_dict = second_circular_all_of_ref_instance.to_dict() +second_circular_all_of_ref_dict = second_circular_all_of_ref_instance.model_dump(by_alias=True) # create an instance of SecondCircularAllOfRef from a dict -second_circular_all_of_ref_from_dict = SecondCircularAllOfRef.from_dict(second_circular_all_of_ref_dict) +second_circular_all_of_ref_from_dict = SecondCircularAllOfRef.model_validate(second_circular_all_of_ref_dict) ``` [[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/SecondRef.md b/samples/openapi3/client/petstore/python/docs/SecondRef.md index dfb1a0ac6db5..fa0b9f285e0c 100644 --- a/samples/openapi3/client/petstore/python/docs/SecondRef.md +++ b/samples/openapi3/client/petstore/python/docs/SecondRef.md @@ -16,14 +16,14 @@ from petstore_api.models.second_ref import SecondRef # TODO update the JSON string below json = "{}" # create an instance of SecondRef from a JSON string -second_ref_instance = SecondRef.from_json(json) +second_ref_instance = SecondRef.model_validate_json(json) # print the JSON string representation of the object -print(SecondRef.to_json()) +print(second_ref_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -second_ref_dict = second_ref_instance.to_dict() +second_ref_dict = second_ref_instance.model_dump(by_alias=True) # create an instance of SecondRef from a dict -second_ref_from_dict = SecondRef.from_dict(second_ref_dict) +second_ref_from_dict = SecondRef.model_validate(second_ref_dict) ``` [[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/SelfReferenceModel.md b/samples/openapi3/client/petstore/python/docs/SelfReferenceModel.md index 208cdac04b6f..af3c77d0524b 100644 --- a/samples/openapi3/client/petstore/python/docs/SelfReferenceModel.md +++ b/samples/openapi3/client/petstore/python/docs/SelfReferenceModel.md @@ -16,14 +16,14 @@ from petstore_api.models.self_reference_model import SelfReferenceModel # TODO update the JSON string below json = "{}" # create an instance of SelfReferenceModel from a JSON string -self_reference_model_instance = SelfReferenceModel.from_json(json) +self_reference_model_instance = SelfReferenceModel.model_validate_json(json) # print the JSON string representation of the object -print(SelfReferenceModel.to_json()) +print(self_reference_model_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -self_reference_model_dict = self_reference_model_instance.to_dict() +self_reference_model_dict = self_reference_model_instance.model_dump(by_alias=True) # create an instance of SelfReferenceModel from a dict -self_reference_model_from_dict = SelfReferenceModel.from_dict(self_reference_model_dict) +self_reference_model_from_dict = SelfReferenceModel.model_validate(self_reference_model_dict) ``` [[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 35303f34efd2..589dbeb14b94 100644 --- a/samples/openapi3/client/petstore/python/docs/SpecialModelName.md +++ b/samples/openapi3/client/petstore/python/docs/SpecialModelName.md @@ -15,14 +15,14 @@ from petstore_api.models.special_model_name import SpecialModelName # TODO update the JSON string below json = "{}" # create an instance of SpecialModelName from a JSON string -special_model_name_instance = SpecialModelName.from_json(json) +special_model_name_instance = SpecialModelName.model_validate_json(json) # print the JSON string representation of the object -print(SpecialModelName.to_json()) +print(special_model_name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -special_model_name_dict = special_model_name_instance.to_dict() +special_model_name_dict = special_model_name_instance.model_dump(by_alias=True) # create an instance of SpecialModelName from a dict -special_model_name_from_dict = SpecialModelName.from_dict(special_model_name_dict) +special_model_name_from_dict = SpecialModelName.model_validate(special_model_name_dict) ``` [[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/SpecialName.md b/samples/openapi3/client/petstore/python/docs/SpecialName.md index ccc550b16e33..19da9016451c 100644 --- a/samples/openapi3/client/petstore/python/docs/SpecialName.md +++ b/samples/openapi3/client/petstore/python/docs/SpecialName.md @@ -17,14 +17,14 @@ from petstore_api.models.special_name import SpecialName # TODO update the JSON string below json = "{}" # create an instance of SpecialName from a JSON string -special_name_instance = SpecialName.from_json(json) +special_name_instance = SpecialName.model_validate_json(json) # print the JSON string representation of the object -print(SpecialName.to_json()) +print(special_name_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -special_name_dict = special_name_instance.to_dict() +special_name_dict = special_name_instance.model_dump(by_alias=True) # create an instance of SpecialName from a dict -special_name_from_dict = SpecialName.from_dict(special_name_dict) +special_name_from_dict = SpecialName.model_validate(special_name_dict) ``` [[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 4106d9cfe5db..66339d14c875 100644 --- a/samples/openapi3/client/petstore/python/docs/Tag.md +++ b/samples/openapi3/client/petstore/python/docs/Tag.md @@ -16,14 +16,14 @@ from petstore_api.models.tag import Tag # TODO update the JSON string below json = "{}" # create an instance of Tag from a JSON string -tag_instance = Tag.from_json(json) +tag_instance = Tag.model_validate_json(json) # print the JSON string representation of the object -print(Tag.to_json()) +print(tag_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tag_dict = tag_instance.to_dict() +tag_dict = tag_instance.model_dump(by_alias=True) # create an instance of Tag from a dict -tag_from_dict = Tag.from_dict(tag_dict) +tag_from_dict = Tag.model_validate(tag_dict) ``` [[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/Task.md b/samples/openapi3/client/petstore/python/docs/Task.md index 85fa2776a059..229ed6510a11 100644 --- a/samples/openapi3/client/petstore/python/docs/Task.md +++ b/samples/openapi3/client/petstore/python/docs/Task.md @@ -17,14 +17,14 @@ from petstore_api.models.task import Task # TODO update the JSON string below json = "{}" # create an instance of Task from a JSON string -task_instance = Task.from_json(json) +task_instance = Task.model_validate_json(json) # print the JSON string representation of the object -print(Task.to_json()) +print(task_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -task_dict = task_instance.to_dict() +task_dict = task_instance.model_dump(by_alias=True) # create an instance of Task from a dict -task_from_dict = Task.from_dict(task_dict) +task_from_dict = Task.model_validate(task_dict) ``` [[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/TaskActivity.md b/samples/openapi3/client/petstore/python/docs/TaskActivity.md index e905a477292d..c025d32ba436 100644 --- a/samples/openapi3/client/petstore/python/docs/TaskActivity.md +++ b/samples/openapi3/client/petstore/python/docs/TaskActivity.md @@ -17,14 +17,14 @@ from petstore_api.models.task_activity import TaskActivity # TODO update the JSON string below json = "{}" # create an instance of TaskActivity from a JSON string -task_activity_instance = TaskActivity.from_json(json) +task_activity_instance = TaskActivity.model_validate_json(json) # print the JSON string representation of the object -print(TaskActivity.to_json()) +print(task_activity_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -task_activity_dict = task_activity_instance.to_dict() +task_activity_dict = task_activity_instance.model_dump(by_alias=True) # create an instance of TaskActivity from a dict -task_activity_from_dict = TaskActivity.from_dict(task_activity_dict) +task_activity_from_dict = TaskActivity.model_validate(task_activity_dict) ``` [[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/TestErrorResponsesWithModel400Response.md b/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel400Response.md index be416bbad0f7..fed06705b55b 100644 --- a/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel400Response.md +++ b/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel400Response.md @@ -15,14 +15,14 @@ from petstore_api.models.test_error_responses_with_model400_response import Test # TODO update the JSON string below json = "{}" # create an instance of TestErrorResponsesWithModel400Response from a JSON string -test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.from_json(json) +test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.model_validate_json(json) # print the JSON string representation of the object -print(TestErrorResponsesWithModel400Response.to_json()) +print(test_error_responses_with_model400_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.to_dict() +test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.model_dump(by_alias=True) # create an instance of TestErrorResponsesWithModel400Response from a dict -test_error_responses_with_model400_response_from_dict = TestErrorResponsesWithModel400Response.from_dict(test_error_responses_with_model400_response_dict) +test_error_responses_with_model400_response_from_dict = TestErrorResponsesWithModel400Response.model_validate(test_error_responses_with_model400_response_dict) ``` [[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/TestErrorResponsesWithModel404Response.md b/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel404Response.md index 1c984f847bf1..8813e0792d22 100644 --- a/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel404Response.md +++ b/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel404Response.md @@ -15,14 +15,14 @@ from petstore_api.models.test_error_responses_with_model404_response import Test # TODO update the JSON string below json = "{}" # create an instance of TestErrorResponsesWithModel404Response from a JSON string -test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.from_json(json) +test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.model_validate_json(json) # print the JSON string representation of the object -print(TestErrorResponsesWithModel404Response.to_json()) +print(test_error_responses_with_model404_response_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.to_dict() +test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.model_dump(by_alias=True) # create an instance of TestErrorResponsesWithModel404Response from a dict -test_error_responses_with_model404_response_from_dict = TestErrorResponsesWithModel404Response.from_dict(test_error_responses_with_model404_response_dict) +test_error_responses_with_model404_response_from_dict = TestErrorResponsesWithModel404Response.model_validate(test_error_responses_with_model404_response_dict) ``` [[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/TestInlineFreeformAdditionalPropertiesRequest.md b/samples/openapi3/client/petstore/python/docs/TestInlineFreeformAdditionalPropertiesRequest.md index 511132d689be..870cd8850e6b 100644 --- a/samples/openapi3/client/petstore/python/docs/TestInlineFreeformAdditionalPropertiesRequest.md +++ b/samples/openapi3/client/petstore/python/docs/TestInlineFreeformAdditionalPropertiesRequest.md @@ -15,14 +15,14 @@ from petstore_api.models.test_inline_freeform_additional_properties_request impo # TODO update the JSON string below json = "{}" # create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string -test_inline_freeform_additional_properties_request_instance = TestInlineFreeformAdditionalPropertiesRequest.from_json(json) +test_inline_freeform_additional_properties_request_instance = TestInlineFreeformAdditionalPropertiesRequest.model_validate_json(json) # print the JSON string representation of the object -print(TestInlineFreeformAdditionalPropertiesRequest.to_json()) +print(test_inline_freeform_additional_properties_request_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_inline_freeform_additional_properties_request_dict = test_inline_freeform_additional_properties_request_instance.to_dict() +test_inline_freeform_additional_properties_request_dict = test_inline_freeform_additional_properties_request_instance.model_dump(by_alias=True) # create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict -test_inline_freeform_additional_properties_request_from_dict = TestInlineFreeformAdditionalPropertiesRequest.from_dict(test_inline_freeform_additional_properties_request_dict) +test_inline_freeform_additional_properties_request_from_dict = TestInlineFreeformAdditionalPropertiesRequest.model_validate(test_inline_freeform_additional_properties_request_dict) ``` [[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/TestModelWithEnumDefault.md b/samples/openapi3/client/petstore/python/docs/TestModelWithEnumDefault.md index 7d46e86deba4..1f63056fe0f1 100644 --- a/samples/openapi3/client/petstore/python/docs/TestModelWithEnumDefault.md +++ b/samples/openapi3/client/petstore/python/docs/TestModelWithEnumDefault.md @@ -19,14 +19,14 @@ from petstore_api.models.test_model_with_enum_default import TestModelWithEnumDe # TODO update the JSON string below json = "{}" # create an instance of TestModelWithEnumDefault from a JSON string -test_model_with_enum_default_instance = TestModelWithEnumDefault.from_json(json) +test_model_with_enum_default_instance = TestModelWithEnumDefault.model_validate_json(json) # print the JSON string representation of the object -print(TestModelWithEnumDefault.to_json()) +print(test_model_with_enum_default_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_model_with_enum_default_dict = test_model_with_enum_default_instance.to_dict() +test_model_with_enum_default_dict = test_model_with_enum_default_instance.model_dump(by_alias=True) # create an instance of TestModelWithEnumDefault from a dict -test_model_with_enum_default_from_dict = TestModelWithEnumDefault.from_dict(test_model_with_enum_default_dict) +test_model_with_enum_default_from_dict = TestModelWithEnumDefault.model_validate(test_model_with_enum_default_dict) ``` [[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/TestObjectForMultipartRequestsRequestMarker.md b/samples/openapi3/client/petstore/python/docs/TestObjectForMultipartRequestsRequestMarker.md index ff0ca9ee00ac..bb685d44835a 100644 --- a/samples/openapi3/client/petstore/python/docs/TestObjectForMultipartRequestsRequestMarker.md +++ b/samples/openapi3/client/petstore/python/docs/TestObjectForMultipartRequestsRequestMarker.md @@ -15,14 +15,14 @@ from petstore_api.models.test_object_for_multipart_requests_request_marker impor # TODO update the JSON string below json = "{}" # create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string -test_object_for_multipart_requests_request_marker_instance = TestObjectForMultipartRequestsRequestMarker.from_json(json) +test_object_for_multipart_requests_request_marker_instance = TestObjectForMultipartRequestsRequestMarker.model_validate_json(json) # print the JSON string representation of the object -print(TestObjectForMultipartRequestsRequestMarker.to_json()) +print(test_object_for_multipart_requests_request_marker_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -test_object_for_multipart_requests_request_marker_dict = test_object_for_multipart_requests_request_marker_instance.to_dict() +test_object_for_multipart_requests_request_marker_dict = test_object_for_multipart_requests_request_marker_instance.model_dump(by_alias=True) # create an instance of TestObjectForMultipartRequestsRequestMarker from a dict -test_object_for_multipart_requests_request_marker_from_dict = TestObjectForMultipartRequestsRequestMarker.from_dict(test_object_for_multipart_requests_request_marker_dict) +test_object_for_multipart_requests_request_marker_from_dict = TestObjectForMultipartRequestsRequestMarker.model_validate(test_object_for_multipart_requests_request_marker_dict) ``` [[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/Tiger.md b/samples/openapi3/client/petstore/python/docs/Tiger.md index f1cf2133f0f7..90c7d8770979 100644 --- a/samples/openapi3/client/petstore/python/docs/Tiger.md +++ b/samples/openapi3/client/petstore/python/docs/Tiger.md @@ -15,14 +15,14 @@ from petstore_api.models.tiger import Tiger # TODO update the JSON string below json = "{}" # create an instance of Tiger from a JSON string -tiger_instance = Tiger.from_json(json) +tiger_instance = Tiger.model_validate_json(json) # print the JSON string representation of the object -print(Tiger.to_json()) +print(tiger_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -tiger_dict = tiger_instance.to_dict() +tiger_dict = tiger_instance.model_dump(by_alias=True) # create an instance of Tiger from a dict -tiger_from_dict = Tiger.from_dict(tiger_dict) +tiger_from_dict = Tiger.model_validate(tiger_dict) ``` [[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/UnnamedDictWithAdditionalModelListProperties.md b/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalModelListProperties.md index 68cd00ab0a7a..0b411bf5df7b 100644 --- a/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalModelListProperties.md +++ b/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalModelListProperties.md @@ -15,14 +15,14 @@ from petstore_api.models.unnamed_dict_with_additional_model_list_properties impo # TODO update the JSON string below json = "{}" # create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string -unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.from_json(json) +unnamed_dict_with_additional_model_list_properties_instance = UnnamedDictWithAdditionalModelListProperties.model_validate_json(json) # print the JSON string representation of the object -print(UnnamedDictWithAdditionalModelListProperties.to_json()) +print(unnamed_dict_with_additional_model_list_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.to_dict() +unnamed_dict_with_additional_model_list_properties_dict = unnamed_dict_with_additional_model_list_properties_instance.model_dump(by_alias=True) # create an instance of UnnamedDictWithAdditionalModelListProperties from a dict -unnamed_dict_with_additional_model_list_properties_from_dict = UnnamedDictWithAdditionalModelListProperties.from_dict(unnamed_dict_with_additional_model_list_properties_dict) +unnamed_dict_with_additional_model_list_properties_from_dict = UnnamedDictWithAdditionalModelListProperties.model_validate(unnamed_dict_with_additional_model_list_properties_dict) ``` [[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/UnnamedDictWithAdditionalStringListProperties.md b/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalStringListProperties.md index 045b0e22ad09..def639720586 100644 --- a/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalStringListProperties.md +++ b/samples/openapi3/client/petstore/python/docs/UnnamedDictWithAdditionalStringListProperties.md @@ -15,14 +15,14 @@ from petstore_api.models.unnamed_dict_with_additional_string_list_properties imp # TODO update the JSON string below json = "{}" # create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string -unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.from_json(json) +unnamed_dict_with_additional_string_list_properties_instance = UnnamedDictWithAdditionalStringListProperties.model_validate_json(json) # print the JSON string representation of the object -print(UnnamedDictWithAdditionalStringListProperties.to_json()) +print(unnamed_dict_with_additional_string_list_properties_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.to_dict() +unnamed_dict_with_additional_string_list_properties_dict = unnamed_dict_with_additional_string_list_properties_instance.model_dump(by_alias=True) # create an instance of UnnamedDictWithAdditionalStringListProperties from a dict -unnamed_dict_with_additional_string_list_properties_from_dict = UnnamedDictWithAdditionalStringListProperties.from_dict(unnamed_dict_with_additional_string_list_properties_dict) +unnamed_dict_with_additional_string_list_properties_from_dict = UnnamedDictWithAdditionalStringListProperties.model_validate(unnamed_dict_with_additional_string_list_properties_dict) ``` [[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/UploadFileWithAdditionalPropertiesRequestObject.md b/samples/openapi3/client/petstore/python/docs/UploadFileWithAdditionalPropertiesRequestObject.md index 141027780371..35be1642e660 100644 --- a/samples/openapi3/client/petstore/python/docs/UploadFileWithAdditionalPropertiesRequestObject.md +++ b/samples/openapi3/client/petstore/python/docs/UploadFileWithAdditionalPropertiesRequestObject.md @@ -16,14 +16,14 @@ from petstore_api.models.upload_file_with_additional_properties_request_object i # TODO update the JSON string below json = "{}" # create an instance of UploadFileWithAdditionalPropertiesRequestObject from a JSON string -upload_file_with_additional_properties_request_object_instance = UploadFileWithAdditionalPropertiesRequestObject.from_json(json) +upload_file_with_additional_properties_request_object_instance = UploadFileWithAdditionalPropertiesRequestObject.model_validate_json(json) # print the JSON string representation of the object -print(UploadFileWithAdditionalPropertiesRequestObject.to_json()) +print(upload_file_with_additional_properties_request_object_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -upload_file_with_additional_properties_request_object_dict = upload_file_with_additional_properties_request_object_instance.to_dict() +upload_file_with_additional_properties_request_object_dict = upload_file_with_additional_properties_request_object_instance.model_dump(by_alias=True) # create an instance of UploadFileWithAdditionalPropertiesRequestObject from a dict -upload_file_with_additional_properties_request_object_from_dict = UploadFileWithAdditionalPropertiesRequestObject.from_dict(upload_file_with_additional_properties_request_object_dict) +upload_file_with_additional_properties_request_object_from_dict = UploadFileWithAdditionalPropertiesRequestObject.model_validate(upload_file_with_additional_properties_request_object_dict) ``` [[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 c45d26d27043..8f4ae3d04712 100644 --- a/samples/openapi3/client/petstore/python/docs/User.md +++ b/samples/openapi3/client/petstore/python/docs/User.md @@ -22,14 +22,14 @@ from petstore_api.models.user import User # TODO update the JSON string below json = "{}" # create an instance of User from a JSON string -user_instance = User.from_json(json) +user_instance = User.model_validate_json(json) # print the JSON string representation of the object -print(User.to_json()) +print(user_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -user_dict = user_instance.to_dict() +user_dict = user_instance.model_dump(by_alias=True) # create an instance of User from a dict -user_from_dict = User.from_dict(user_dict) +user_from_dict = User.model_validate(user_dict) ``` [[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/WithNestedOneOf.md b/samples/openapi3/client/petstore/python/docs/WithNestedOneOf.md index e7bbbc28fc2d..12d648bb920d 100644 --- a/samples/openapi3/client/petstore/python/docs/WithNestedOneOf.md +++ b/samples/openapi3/client/petstore/python/docs/WithNestedOneOf.md @@ -17,14 +17,14 @@ from petstore_api.models.with_nested_one_of import WithNestedOneOf # TODO update the JSON string below json = "{}" # create an instance of WithNestedOneOf from a JSON string -with_nested_one_of_instance = WithNestedOneOf.from_json(json) +with_nested_one_of_instance = WithNestedOneOf.model_validate_json(json) # print the JSON string representation of the object -print(WithNestedOneOf.to_json()) +print(with_nested_one_of_instance.model_dump_json(by_alias=True, exclude_unset=True)) # convert the object into a dict -with_nested_one_of_dict = with_nested_one_of_instance.to_dict() +with_nested_one_of_dict = with_nested_one_of_instance.model_dump(by_alias=True) # create an instance of WithNestedOneOf from a dict -with_nested_one_of_from_dict = WithNestedOneOf.from_dict(with_nested_one_of_dict) +with_nested_one_of_from_dict = WithNestedOneOf.model_validate(with_nested_one_of_dict) ``` [[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/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py index 291b5e55e353..9c810c176590 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesAnyType(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesAnyType(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesAnyType from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesAnyType from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py index 220f23a423b4..a17e1f1dcb36 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesClass(BaseModel): """ @@ -38,65 +39,27 @@ class AdditionalPropertiesClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "map_property": obj.get("map_property"), - "map_of_map_property": obj.get("map_of_map_property") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py index 00707c3c4818..75df3dc97cf4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesObject(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py index d8049b519ed0..a3dea0ab8ee6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AdditionalPropertiesWithDescriptionOnly(BaseModel): """ @@ -37,64 +38,27 @@ class AdditionalPropertiesWithDescriptionOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py index b63bba1206a2..bcab36b1dbec 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AllOfSuperModel(BaseModel): """ @@ -37,64 +38,27 @@ class AllOfSuperModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AllOfSuperModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AllOfSuperModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py index e3fa084b0709..7fad1a2d3b87 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.single_ref_type import SingleRefType from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class AllOfWithSingleRef(BaseModel): """ @@ -39,65 +40,27 @@ class AllOfWithSingleRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AllOfWithSingleRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AllOfWithSingleRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "username": obj.get("username"), - "SingleRefType": obj.get("SingleRefType") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py index 131ad8d0ed60..5826bb1f15f1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -61,59 +62,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[Cat, Dog]]: - """Create an instance of Animal from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[Cat, Dog]]: - """Create an instance of Animal from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'Cat': - return import_module("petstore_api.models.cat").Cat.from_dict(obj) - if object_type == 'Dog': - return import_module("petstore_api.models.dog").Dog.from_dict(obj) - - raise ValueError("Animal failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py index f6d277e79498..b86b03be3591 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py @@ -13,8 +13,6 @@ from __future__ import annotations -from inspect import getfullargspec -import json import pprint import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator @@ -22,135 +20,56 @@ from typing_extensions import Annotated from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field +from pydantic import Field, RootModel ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] -class AnyOfColor(BaseModel): + +class AnyOfColor(RootModel[Union[List[int], str]]): """ Any of RGB array, RGBA array, or hex string. """ - # data type: List[int] - anyof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") - # data type: List[int] - anyof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") - # data type: str - anyof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") - if TYPE_CHECKING: - actual_instance: Optional[Union[List[int], str]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { "List[int]", "str" } - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfColor.model_construct() - error_messages = [] - # validate data type: List[int] - try: - instance.anyof_schema_1_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: List[int] - try: - instance.anyof_schema_2_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.anyof_schema_3_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return v + root: Union[List[int], str] = Field( + ... + ) + + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ + + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Self: - return cls.from_json(json.dumps(obj)) + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - # deserialize data into List[int] - try: - # validation - instance.anyof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_1_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into List[int] - try: - # validation - instance.anyof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_2_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.anyof_schema_3_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_3_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into AnyOfColor with anyOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) + return self.model_dump_json(by_alias=True, exclude_none=True) - def to_dict(self) -> Optional[Union[Dict[str, Any], List[int], str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py index c949e136f415..a632d3c382d6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -from inspect import getfullargspec -import json import pprint import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator @@ -23,112 +21,56 @@ from petstore_api.models.danish_pig import DanishPig from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field +from pydantic import Field, RootModel ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] -class AnyOfPig(BaseModel): + +class AnyOfPig(RootModel[Union[BasquePig, DanishPig]]): """ AnyOfPig """ - # data type: BasquePig - anyof_schema_1_validator: Optional[BasquePig] = None - # data type: DanishPig - anyof_schema_2_validator: Optional[DanishPig] = None - if TYPE_CHECKING: - actual_instance: Optional[Union[BasquePig, DanishPig]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { "BasquePig", "DanishPig" } - - model_config = { - "validate_assignment": True, - "protected_namespaces": (), - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - instance = AnyOfPig.model_construct() - error_messages = [] - # validate data type: BasquePig - if not isinstance(v, BasquePig): - error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") - else: - return v - - # validate data type: DanishPig - if not isinstance(v, DanishPig): - error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") - else: - return v - - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return v + root: Union[BasquePig, DanishPig] = Field( + ... + ) + + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ + + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod def from_dict(cls, obj: Dict[str, Any]) -> Self: - return cls.from_json(json.dumps(obj)) + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - # anyof_schema_1_validator: Optional[BasquePig] = None - try: - instance.actual_instance = BasquePig.from_json(json_str) - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # anyof_schema_2_validator: Optional[DanishPig] = None - try: - instance.actual_instance = DanishPig.from_json(json_str) - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) + return self.model_dump_json(by_alias=True, exclude_none=True) - def to_dict(self) -> Optional[Union[Dict[str, Any], BasquePig, DanishPig]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py index 80d4aa689164..2607cb555897 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfArrayOfModel(BaseModel): """ @@ -38,76 +39,27 @@ class ArrayOfArrayOfModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) - _items = [] - if self.another_property: - for _item_another_property in self.another_property: - if _item_another_property: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] - ) - _dict['another_property'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "another_property": [ - [Tag.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["another_property"] - ] if obj.get("another_property") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index 847ae88c4ffa..b3502813e131 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictFloat from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfArrayOfNumberOnly(BaseModel): """ @@ -37,64 +38,27 @@ class ArrayOfArrayOfNumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfNumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfArrayOfNumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "ArrayArrayNumber": obj.get("ArrayArrayNumber") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py index 4634914c33eb..40b76b10e2e8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictFloat from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayOfNumberOnly(BaseModel): """ @@ -37,64 +38,27 @@ class ArrayOfNumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayOfNumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayOfNumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "ArrayNumber": obj.get("ArrayNumber") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py index 9cadd4e7beb7..1ef35ed4290a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py @@ -22,7 +22,8 @@ from typing_extensions import Annotated from petstore_api.models.read_only_first import ReadOnlyFirst from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ArrayTest(BaseModel): """ @@ -42,79 +43,27 @@ class ArrayTest(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ArrayTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) - _items = [] - if self.array_array_of_model: - for _item_array_array_of_model in self.array_array_of_model: - if _item_array_array_of_model: - _items.append( - [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] - ) - _dict['array_array_of_model'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ArrayTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "array_of_string": obj.get("array_of_string"), - "array_of_nullable_float": obj.get("array_of_nullable_float"), - "array_array_of_integer": obj.get("array_array_of_integer"), - "array_array_of_model": [ - [ReadOnlyFirst.from_dict(_inner_item) for _inner_item in _item] - for _item in obj["array_array_of_model"] - ] if obj.get("array_array_of_model") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py index 40b49a2fca7f..6c414fe72920 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -60,59 +61,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[PrimitiveString, Info]]: - """Create an instance of BaseDiscriminator from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[PrimitiveString, Info]]: - """Create an instance of BaseDiscriminator from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'PrimitiveString': - return import_module("petstore_api.models.primitive_string").PrimitiveString.from_dict(obj) - if object_type == 'Info': - return import_module("petstore_api.models.info").Info.from_dict(obj) - - raise ValueError("BaseDiscriminator failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py index 4a5b9e3bcb9d..ef9d50223015 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class BasquePig(BaseModel): """ @@ -38,65 +39,27 @@ class BasquePig(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of BasquePig from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of BasquePig from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py index 289d9d4670ab..c81fd1e1c2ec 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Bathing(BaseModel): """ Bathing """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning_deep'] = Field( + ..., + description="task_name of the Bathing", + alias="task_name" + ) + function_name: Literal['care_nourish'] = Field( + ..., + description="function_name of the Bathing", + alias="function_name" + ) content: StrictStr additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -53,66 +62,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Bathing from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Bathing from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py index d98aa21e532d..e672f06cf876 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Capitalization(BaseModel): """ @@ -42,69 +43,27 @@ class Capitalization(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Capitalization from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Capitalization from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "smallCamel": obj.get("smallCamel"), - "CapitalCamel": obj.get("CapitalCamel"), - "small_Snake": obj.get("small_Snake"), - "Capital_Snake": obj.get("Capital_Snake"), - "SCA_ETH_Flow_Points": obj.get("SCA_ETH_Flow_Points"), - "ATT_NAME": obj.get("ATT_NAME") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py index 86002178c904..2ab12e0b0b08 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Cat(Animal): """ @@ -38,66 +39,27 @@ class Cat(Animal): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Cat from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Cat from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") if obj.get("color") is not None else 'red', - "declawed": obj.get("declawed") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/category.py b/samples/openapi3/client/petstore/python/petstore_api/models/category.py index c659f1845726..a832b700194a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/category.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Category(BaseModel): """ @@ -38,65 +39,27 @@ class Category(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Category from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Category from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") if obj.get("name") is not None else 'default-name' - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py index d3b6cbe57ea1..c08dfce51988 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CircularAllOfRef(BaseModel): """ @@ -38,73 +39,28 @@ class CircularAllOfRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CircularAllOfRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in second_circular_all_of_ref (list) - _items = [] - if self.second_circular_all_of_ref: - for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: - if _item_second_circular_all_of_ref: - _items.append(_item_second_circular_all_of_ref.to_dict()) - _dict['secondCircularAllOfRef'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CircularAllOfRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name"), - "secondCircularAllOfRef": [SecondCircularAllOfRef.from_dict(_item) for _item in obj["secondCircularAllOfRef"]] if obj.get("secondCircularAllOfRef") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py index 8c118f3c09b2..a4397f923a4b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CircularReferenceModel(BaseModel): """ @@ -38,69 +39,28 @@ class CircularReferenceModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CircularReferenceModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested - if self.nested: - _dict['nested'] = self.nested.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CircularReferenceModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested": FirstRef.from_dict(obj["nested"]) if obj.get("nested") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.first_ref import FirstRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py index 06f8f91b83cb..a0db951aaa5e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ClassModel(BaseModel): """ @@ -37,64 +38,27 @@ class ClassModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ClassModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ClassModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_class": obj.get("_class") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/client.py b/samples/openapi3/client/petstore/python/petstore_api/models/client.py index d3376d62357b..5a12db40db07 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/client.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Client(BaseModel): """ @@ -37,64 +38,27 @@ class Client(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Client from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Client from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "client": obj.get("client") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/color.py b/samples/openapi3/client/petstore/python/petstore_api/models/color.py index bb740fb597d4..5197fe58ecc6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/color.py @@ -18,150 +18,55 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] -class Color(BaseModel): +class Color(RootModel[Union[List[int], str]]): """ RGB array, RGBA array, or hex string. """ - # data type: List[int] - oneof_schema_1_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=3, max_length=3)]] = Field(default=None, description="RGB three element array with values 0-255.") - # data type: List[int] - oneof_schema_2_validator: Optional[Annotated[List[Annotated[int, Field(le=255, strict=True, ge=0)]], Field(min_length=4, max_length=4)]] = Field(default=None, description="RGBA four element array with values 0-255.") - # data type: str - oneof_schema_3_validator: Optional[Annotated[str, Field(min_length=7, strict=True, max_length=7)]] = Field(default=None, description="Hex color string, such as #00FF00.") - actual_instance: Optional[Union[List[int], str]] = None - one_of_schemas: Set[str] = { "List[int]", "str" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[List[int], str, None] = Field( + None ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - if v is None: - return v - - instance = Color.model_construct() - error_messages = [] - match = 0 - # validate data type: List[int] - try: - instance.oneof_schema_1_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: List[int] - try: - instance.oneof_schema_2_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.oneof_schema_3_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: Optional[str]) -> Self: + def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - if json_str is None: - return instance - - error_messages = [] - match = 0 - - # deserialize data into List[int] - try: - # validation - instance.oneof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_1_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into List[int] - try: - # validation - instance.oneof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_2_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.oneof_schema_3_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_3_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into Color with oneOf schemas: List[int], str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], List[int], str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py index ce6a70327b1a..17379d6ff774 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -22,7 +22,8 @@ from typing import Any, ClassVar, Dict, List, Union from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -61,60 +62,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[HuntingDog]]: - """Create an instance of Creature from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of info - if self.info: - _dict['info'] = self.info.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[HuntingDog]]: - """Create an instance of Creature from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'HuntingDog': - return import_module("petstore_api.models.hunting_dog").HuntingDog.from_dict(obj) - - raise ValueError("Creature failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py index e7fef158a580..33414bb2e4f6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class CreatureInfo(BaseModel): """ @@ -37,64 +38,27 @@ class CreatureInfo(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of CreatureInfo from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of CreatureInfo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py index df4a80d33908..b2e7e8e9c884 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DanishPig(BaseModel): """ @@ -38,65 +39,27 @@ class DanishPig(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DanishPig from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DanishPig from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "size": obj.get("size") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py index ad0ec89a5b7a..eeed19fe0293 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DeprecatedObject(BaseModel): """ @@ -37,64 +38,27 @@ class DeprecatedObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DeprecatedObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DeprecatedObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py index 9723d2e28c74..23c07b3cc8cd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List from petstore_api.models.discriminator_all_of_super import DiscriminatorAllOfSuper from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DiscriminatorAllOfSub(DiscriminatorAllOfSuper): """ @@ -37,64 +38,27 @@ class DiscriminatorAllOfSub(DiscriminatorAllOfSuper): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DiscriminatorAllOfSub from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DiscriminatorAllOfSub from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "elementType": obj.get("elementType") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py index e3d62831065a..424c25871dc8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Union from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -59,57 +60,27 @@ def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]: else: return None - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Union[DiscriminatorAllOfSub]]: - """Create an instance of DiscriminatorAllOfSuper from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[DiscriminatorAllOfSub]]: - """Create an instance of DiscriminatorAllOfSuper from a dict""" - # look up the object type based on discriminator mapping - object_type = cls.get_discriminator_value(obj) - if object_type == 'DiscriminatorAllOfSub': - return import_module("petstore_api.models.discriminator_all_of_sub").DiscriminatorAllOfSub.from_dict(obj) - - raise ValueError("DiscriminatorAllOfSuper failed to lookup discriminator value from " + - json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name + - ", mapping: " + json.dumps(cls.__discriminator_value_class_map)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py index cde0f5d27e0c..ab08540bc824 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Dog(Animal): """ @@ -38,66 +39,27 @@ class Dog(Animal): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Dog from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Dog from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "className": obj.get("className"), - "color": obj.get("color") if obj.get("color") is not None else 'red', - "breed": obj.get("breed") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py index 47fdb81a397a..339439a15b66 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class DummyModel(BaseModel): """ @@ -38,69 +39,28 @@ class DummyModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DummyModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of self_ref - if self.self_ref: - _dict['self_ref'] = self.self_ref.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DummyModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "self_ref": SelfReferenceModel.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.self_reference_model import SelfReferenceModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py index 17d3e0afd2df..4727cd9180b5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py @@ -20,14 +20,21 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumArrays(BaseModel): """ EnumArrays """ # noqa: E501 - just_symbol: Optional[StrictStr] = None - array_enum: Optional[List[StrictStr]] = None + just_symbol: Optional[Literal['>=', '$']] = Field( + None, + description="just_symbol of the EnumArrays" + ) + array_enum: Optional[List[Literal['fish', 'crab']]] = Field( + None, + description="array_enum of the EnumArrays" + ) additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["just_symbol", "array_enum"] @@ -59,65 +66,27 @@ def array_enum_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumArrays from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumArrays from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "just_symbol": obj.get("just_symbol"), - "array_enum": obj.get("array_enum") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py index d864e80d0a73..5f3ded3bd569 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.data_output_format import DataOutputFormat from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumRefWithDefaultValue(BaseModel): """ @@ -38,64 +39,27 @@ class EnumRefWithDefaultValue(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumRefWithDefaultValue from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumRefWithDefaultValue from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "report_format": obj.get("report_format") if obj.get("report_format") is not None else DataOutputFormat.JSON - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index d39c2c95775e..f38e8375d0f8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -26,19 +26,43 @@ from petstore_api.models.outer_enum_integer import OuterEnumInteger from petstore_api.models.outer_enum_integer_default_value import OuterEnumIntegerDefaultValue from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class EnumTest(BaseModel): """ EnumTest """ # noqa: E501 - enum_string: Optional[StrictStr] = None - enum_string_required: StrictStr - enum_integer_default: Optional[StrictInt] = 5 - enum_integer: Optional[StrictInt] = None - enum_number: Optional[StrictFloat] = None - enum_string_single_member: Optional[StrictStr] = None - enum_integer_single_member: Optional[StrictInt] = None + enum_string: Optional[Literal['UPPER', 'lower', '']] = Field( + None, + description="enum_string of the EnumTest" + ) + enum_string_required: Literal['UPPER', 'lower', ''] = Field( + ..., + description="enum_string_required of the EnumTest" + ) + enum_integer_default: Optional[Literal[1, 5, 14]] = Field( + None, + description="enum_integer_default of the EnumTest" + ) + enum_integer: Optional[Literal[1, -1]] = Field( + None, + description="enum_integer of the EnumTest" + ) + enum_number: Optional[Literal[1.1, -1.2]] = Field( + None, + description="enum_number of the EnumTest" + ) + enum_string_single_member: Literal['abc'] = Field( + None, + description="enum_string_single_member of the EnumTest", + alias="enum_string_single_member" + ) + enum_integer_single_member: Literal['100'] = Field( + None, + description="enum_integer_single_member of the EnumTest", + alias="enum_integer_single_member" + ) outer_enum: Optional[OuterEnum] = Field(default=None, alias="outerEnum") outer_enum_integer: Optional[OuterEnumInteger] = Field(default=None, alias="outerEnumInteger") outer_enum_default_value: Optional[OuterEnumDefaultValue] = Field(default=OuterEnumDefaultValue.PLACED, alias="outerEnumDefaultValue") @@ -122,81 +146,27 @@ def enum_integer_single_member_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of EnumTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if outer_enum (nullable) is None - # and model_fields_set contains the field - if self.outer_enum is None and "outer_enum" in self.model_fields_set: - _dict['outerEnum'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of EnumTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "enum_string": obj.get("enum_string"), - "enum_string_required": obj.get("enum_string_required"), - "enum_integer_default": obj.get("enum_integer_default") if obj.get("enum_integer_default") is not None else 5, - "enum_integer": obj.get("enum_integer"), - "enum_number": obj.get("enum_number"), - "enum_string_single_member": obj.get("enum_string_single_member"), - "enum_integer_single_member": obj.get("enum_integer_single_member"), - "outerEnum": obj.get("outerEnum"), - "outerEnumInteger": obj.get("outerEnumInteger"), - "outerEnumDefaultValue": obj.get("outerEnumDefaultValue") if obj.get("outerEnumDefaultValue") is not None else OuterEnumDefaultValue.PLACED, - "outerEnumIntegerDefaultValue": obj.get("outerEnumIntegerDefaultValue") if obj.get("outerEnumIntegerDefaultValue") is not None else OuterEnumIntegerDefaultValue.NUMBER_0, - "enumNumberVendorExt": obj.get("enumNumberVendorExt"), - "enumStringVendorExt": obj.get("enumStringVendorExt") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py index 5c406bc9e65e..bf9365e5b6bc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Feeding(BaseModel): """ Feeding """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning'] = Field( + ..., + description="task_name of the Feeding", + alias="task_name" + ) + function_name: Literal['care_nourish'] = Field( + ..., + description="function_name of the Feeding", + alias="function_name" + ) content: StrictStr additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -53,66 +62,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Feeding from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Feeding from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file.py b/samples/openapi3/client/petstore/python/petstore_api/models/file.py index 4c661cadabc4..ee16b0236916 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class File(BaseModel): """ @@ -37,64 +38,27 @@ class File(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of File from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of File from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "sourceURI": obj.get("sourceURI") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py index 09a543010f4d..ed0e54ef78e5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.file import File from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FileSchemaTestClass(BaseModel): """ @@ -39,75 +40,27 @@ class FileSchemaTestClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FileSchemaTestClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of file - if self.file: - _dict['file'] = self.file.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in files (list) - _items = [] - if self.files: - for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) - _dict['files'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FileSchemaTestClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "file": File.from_dict(obj["file"]) if obj.get("file") is not None else None, - "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py index 7680dfdf418c..0fb22f81f548 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FirstRef(BaseModel): """ @@ -38,69 +39,28 @@ class FirstRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FirstRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of self_ref - if self.self_ref: - _dict['self_ref'] = self.self_ref.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FirstRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "self_ref": SecondRef.from_dict(obj["self_ref"]) if obj.get("self_ref") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.second_ref import SecondRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py index 81e3839ea17c..441022bc8977 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Foo(BaseModel): """ @@ -37,64 +38,27 @@ class Foo(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Foo from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Foo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar") if obj.get("bar") is not None else 'bar' - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py index 4cd23db39125..deac653ae358 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.foo import Foo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FooGetDefaultResponse(BaseModel): """ @@ -38,67 +39,27 @@ class FooGetDefaultResponse(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FooGetDefaultResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of string - if self.string: - _dict['string'] = self.string.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FooGetDefaultResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "string": Foo.from_dict(obj["string"]) if obj.get("string") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py index 4aca97f91c48..2960e7f390c8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py @@ -24,7 +24,8 @@ from typing_extensions import Annotated from uuid import UUID from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class FormatTest(BaseModel): """ @@ -97,80 +98,27 @@ def pattern_with_digits_and_delimiter_validate_regular_expression(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of FormatTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of FormatTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "integer": obj.get("integer"), - "int32": obj.get("int32"), - "int64": obj.get("int64"), - "number": obj.get("number"), - "float": obj.get("float"), - "double": obj.get("double"), - "decimal": obj.get("decimal"), - "string": obj.get("string"), - "string_with_double_quote_pattern": obj.get("string_with_double_quote_pattern"), - "byte": obj.get("byte"), - "binary": obj.get("binary"), - "date": obj.get("date"), - "dateTime": obj.get("dateTime"), - "uuid": obj.get("uuid"), - "password": obj.get("password"), - "pattern_with_digits": obj.get("pattern_with_digits"), - "pattern_with_digits_and_delimiter": obj.get("pattern_with_digits_and_delimiter") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py index 77360fedbae5..970814db675e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HasOnlyReadOnly(BaseModel): """ @@ -38,69 +39,27 @@ class HasOnlyReadOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HasOnlyReadOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * OpenAPI `readOnly` fields are excluded. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "bar", - "foo", - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HasOnlyReadOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar"), - "foo": obj.get("foo") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py index 59f444aedaa3..658fdb690194 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HealthCheckResult(BaseModel): """ @@ -37,69 +38,27 @@ class HealthCheckResult(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HealthCheckResult from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if nullable_message (nullable) is None - # and model_fields_set contains the field - if self.nullable_message is None and "nullable_message" in self.model_fields_set: - _dict['NullableMessage'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HealthCheckResult from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "NullableMessage": obj.get("NullableMessage") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py index f7d03f4044ea..05c5aef54690 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py @@ -22,7 +22,8 @@ from petstore_api.models.creature import Creature from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class HuntingDog(Creature): """ @@ -39,69 +40,27 @@ class HuntingDog(Creature): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of HuntingDog from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of info - if self.info: - _dict['info'] = self.info.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of HuntingDog from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "info": CreatureInfo.from_dict(obj["info"]) if obj.get("info") is not None else None, - "type": obj.get("type"), - "isTrained": obj.get("isTrained") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/info.py b/samples/openapi3/client/petstore/python/petstore_api/models/info.py index 94e663b3aaab..0eb710f31a1c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/info.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.base_discriminator import BaseDiscriminator from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Info(BaseDiscriminator): """ @@ -38,68 +39,27 @@ class Info(BaseDiscriminator): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Info from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of val - if self.val: - _dict['val'] = self.val.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Info from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_typeName": obj.get("_typeName"), - "val": BaseDiscriminator.from_dict(obj["val"]) if obj.get("val") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py index b43fa8b19fef..7085980c441b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class InnerDictWithProperty(BaseModel): """ @@ -37,64 +38,27 @@ class InnerDictWithProperty(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of InnerDictWithProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of InnerDictWithProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "aProperty": obj.get("aProperty") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py index e4a81ff70006..37d9c2b8d285 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class InputAllOf(BaseModel): """ @@ -38,76 +39,27 @@ class InputAllOf(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of InputAllOf from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) - _field_dict = {} - if self.some_data: - for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - _dict['some_data'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of InputAllOf from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "some_data": dict( - (_k, Tag.from_dict(_v)) - for _k, _v in obj["some_data"].items() - ) - if obj.get("some_data") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py index f2a5a0a2d4a3..c66bf1ab9772 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py @@ -18,127 +18,55 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] -class IntOrString(BaseModel): +class IntOrString(RootModel[Union[int, str]]): """ IntOrString """ - # data type: int - oneof_schema_1_validator: Optional[Annotated[int, Field(strict=True, ge=10)]] = None - # data type: str - oneof_schema_2_validator: Optional[StrictStr] = None - actual_instance: Optional[Union[int, str]] = None - one_of_schemas: Set[str] = { "int", "str" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[int, str] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = IntOrString.model_construct() - error_messages = [] - match = 0 - # validate data type: int - try: - instance.oneof_schema_1_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.oneof_schema_2_validator = v - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into int - try: - # validation - instance.oneof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_1_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.oneof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.oneof_schema_2_validator - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into IntOrString with oneOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py index e00f3d820b88..12892c065284 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ListClass(BaseModel): """ @@ -37,64 +38,27 @@ class ListClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ListClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ListClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "123-list": obj.get("123-list") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index 68816ab29531..c5668fc1865f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MapOfArrayOfModel(BaseModel): """ @@ -38,80 +39,27 @@ class MapOfArrayOfModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MapOfArrayOfModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array) - _field_dict_of_array = {} - if self.shop_id_to_org_online_lip_map: - for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: - if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: - _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ - _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] - ] - _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MapOfArrayOfModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "shopIdToOrgOnlineLipMap": dict( - (_k, - [Tag.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("shopIdToOrgOnlineLipMap", {}).items() - ) - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py index 4cefd36427f9..a8fee7d14e6f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py @@ -20,14 +20,18 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MapTest(BaseModel): """ MapTest """ # noqa: E501 map_map_of_string: Optional[Dict[str, Dict[str, StrictStr]]] = None - map_of_enum_string: Optional[Dict[str, StrictStr]] = None + map_of_enum_string: Optional[Literal['UPPER', 'lower']] = Field( + None, + description="map_of_enum_string of the MapTest" + ) direct_map: Optional[Dict[str, StrictBool]] = None indirect_map: Optional[Dict[str, StrictBool]] = None additional_properties: Dict[str, Any] = {} @@ -51,67 +55,27 @@ def map_of_enum_string_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MapTest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MapTest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "map_map_of_string": obj.get("map_map_of_string"), - "map_of_enum_string": obj.get("map_of_enum_string"), - "direct_map": obj.get("direct_map"), - "indirect_map": obj.get("indirect_map") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index c21f442bb798..f2b040b8b0d9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -23,7 +23,8 @@ from uuid import UUID from petstore_api.models.animal import Animal from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): """ @@ -42,78 +43,27 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in map (dict) - _field_dict = {} - if self.map: - for _key_map in self.map: - if self.map[_key_map]: - _field_dict[_key_map] = self.map[_key_map].to_dict() - _dict['map'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MixedPropertiesAndAdditionalPropertiesClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "uuid": obj.get("uuid"), - "dateTime": obj.get("dateTime"), - "map": dict( - (_k, Animal.from_dict(_v)) - for _k, _v in obj["map"].items() - ) - if obj.get("map") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py index 60e43a0e28e6..2ed302bf3dda 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Model200Response(BaseModel): """ @@ -38,65 +39,27 @@ class Model200Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Model200Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Model200Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "class": obj.get("class") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py index 7141160c57d9..5024a3748f4c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelApiResponse(BaseModel): """ @@ -39,66 +40,27 @@ class ModelApiResponse(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelApiResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelApiResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "code": obj.get("code"), - "type": obj.get("type"), - "message": obj.get("message") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py index d7b03848fe16..c383206e7f01 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelField(BaseModel): """ @@ -37,64 +38,27 @@ class ModelField(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelField from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelField from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "field": obj.get("field") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py index 3f2558bc6e7d..a50cfe4de892 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ModelReturn(BaseModel): """ @@ -37,64 +38,27 @@ class ModelReturn(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ModelReturn from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ModelReturn from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "return": obj.get("return") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py index 80fa67f8a11c..776597336558 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py @@ -22,7 +22,8 @@ from petstore_api.models.file import File from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class MultiArrays(BaseModel): """ @@ -40,79 +41,27 @@ class MultiArrays(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MultiArrays from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - # override the default output from pydantic by calling `to_dict()` of each item in files (list) - _items = [] - if self.files: - for _item_files in self.files: - if _item_files: - _items.append(_item_files.to_dict()) - _dict['files'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MultiArrays from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/name.py b/samples/openapi3/client/petstore/python/petstore_api/models/name.py index 01b02f834137..0a142fc76a55 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/name.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Name(BaseModel): """ @@ -40,71 +41,27 @@ class Name(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Name from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * OpenAPI `readOnly` fields are excluded. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "snake_case", - "var_123_number", - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Name from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "snake_case": obj.get("snake_case"), - "property": obj.get("property"), - "123Number": obj.get("123Number") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py index cb27fbf691c2..9af5bd4422e9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NullableClass(BaseModel): """ @@ -50,131 +51,27 @@ class NullableClass(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NullableClass from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if required_integer_prop (nullable) is None - # and model_fields_set contains the field - if self.required_integer_prop is None and "required_integer_prop" in self.model_fields_set: - _dict['required_integer_prop'] = None - - # set to None if integer_prop (nullable) is None - # and model_fields_set contains the field - if self.integer_prop is None and "integer_prop" in self.model_fields_set: - _dict['integer_prop'] = None - - # set to None if number_prop (nullable) is None - # and model_fields_set contains the field - if self.number_prop is None and "number_prop" in self.model_fields_set: - _dict['number_prop'] = None - - # set to None if boolean_prop (nullable) is None - # and model_fields_set contains the field - if self.boolean_prop is None and "boolean_prop" in self.model_fields_set: - _dict['boolean_prop'] = None - - # set to None if string_prop (nullable) is None - # and model_fields_set contains the field - if self.string_prop is None and "string_prop" in self.model_fields_set: - _dict['string_prop'] = None - - # set to None if date_prop (nullable) is None - # and model_fields_set contains the field - if self.date_prop is None and "date_prop" in self.model_fields_set: - _dict['date_prop'] = None - - # set to None if datetime_prop (nullable) is None - # and model_fields_set contains the field - if self.datetime_prop is None and "datetime_prop" in self.model_fields_set: - _dict['datetime_prop'] = None - - # set to None if array_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.array_nullable_prop is None and "array_nullable_prop" in self.model_fields_set: - _dict['array_nullable_prop'] = None - - # set to None if array_and_items_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.array_and_items_nullable_prop is None and "array_and_items_nullable_prop" in self.model_fields_set: - _dict['array_and_items_nullable_prop'] = None - - # set to None if object_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.object_nullable_prop is None and "object_nullable_prop" in self.model_fields_set: - _dict['object_nullable_prop'] = None - - # set to None if object_and_items_nullable_prop (nullable) is None - # and model_fields_set contains the field - if self.object_and_items_nullable_prop is None and "object_and_items_nullable_prop" in self.model_fields_set: - _dict['object_and_items_nullable_prop'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NullableClass from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "required_integer_prop": obj.get("required_integer_prop"), - "integer_prop": obj.get("integer_prop"), - "number_prop": obj.get("number_prop"), - "boolean_prop": obj.get("boolean_prop"), - "string_prop": obj.get("string_prop"), - "date_prop": obj.get("date_prop"), - "datetime_prop": obj.get("datetime_prop"), - "array_nullable_prop": obj.get("array_nullable_prop"), - "array_and_items_nullable_prop": obj.get("array_and_items_nullable_prop"), - "array_items_nullable": obj.get("array_items_nullable"), - "object_nullable_prop": obj.get("object_nullable_prop"), - "object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"), - "object_items_nullable": obj.get("object_items_nullable") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py index e73cd1509c90..97e118cfed4b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NullableProperty(BaseModel): """ @@ -49,70 +50,27 @@ def name_validate_regular_expression(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NullableProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if name (nullable) is None - # and model_fields_set contains the field - if self.name is None and "name" in self.model_fields_set: - _dict['name'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NullableProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py index f74010e908bb..4cbf63e51f9f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictFloat from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class NumberOnly(BaseModel): """ @@ -37,64 +38,27 @@ class NumberOnly(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of NumberOnly from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of NumberOnly from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "JustNumber": obj.get("JustNumber") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py index 097bdd34e2be..19e4e0a5b32f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictBool from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ObjectToTestAdditionalProperties(BaseModel): """ @@ -37,64 +38,27 @@ class ObjectToTestAdditionalProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ObjectToTestAdditionalProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ObjectToTestAdditionalProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "property": obj.get("property") if obj.get("property") is not None else False - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py index 0c0cc840680b..94e9f98754b1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.deprecated_object import DeprecatedObject from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ObjectWithDeprecatedFields(BaseModel): """ @@ -41,70 +42,27 @@ class ObjectWithDeprecatedFields(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ObjectWithDeprecatedFields from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of deprecated_ref - if self.deprecated_ref: - _dict['deprecatedRef'] = self.deprecated_ref.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ObjectWithDeprecatedFields from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "uuid": obj.get("uuid"), - "id": obj.get("id"), - "deprecatedRef": DeprecatedObject.from_dict(obj["deprecatedRef"]) if obj.get("deprecatedRef") is not None else None, - "bars": obj.get("bars") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py index f180178737db..bdbbebe0e1c4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py @@ -19,119 +19,55 @@ from typing import Any, List, Optional from petstore_api.models.enum_string1 import EnumString1 from petstore_api.models.enum_string2 import EnumString2 -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] -class OneOfEnumString(BaseModel): +class OneOfEnumString(RootModel[Union[EnumString1, EnumString2]]): """ oneOf enum strings """ - # data type: EnumString1 - oneof_schema_1_validator: Optional[EnumString1] = None - # data type: EnumString2 - oneof_schema_2_validator: Optional[EnumString2] = None - actual_instance: Optional[Union[EnumString1, EnumString2]] = None - one_of_schemas: Set[str] = { "EnumString1", "EnumString2" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[EnumString1, EnumString2] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = OneOfEnumString.model_construct() - error_messages = [] - match = 0 - # validate data type: EnumString1 - if not isinstance(v, EnumString1): - error_messages.append(f"Error! Input type `{type(v)}` is not `EnumString1`") - else: - match += 1 - # validate data type: EnumString2 - if not isinstance(v, EnumString2): - error_messages.append(f"Error! Input type `{type(v)}` is not `EnumString2`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into EnumString1 - try: - instance.actual_instance = EnumString1.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into EnumString2 - try: - instance.actual_instance = EnumString2.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into OneOfEnumString with oneOf schemas: EnumString1, EnumString2. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], EnumString1, EnumString2]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/order.py b/samples/openapi3/client/petstore/python/petstore_api/models/order.py index 12dd1ef117d2..a5c50a094a0b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -21,7 +21,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Order(BaseModel): """ @@ -31,7 +32,10 @@ class Order(BaseModel): pet_id: Optional[StrictInt] = Field(default=None, alias="petId") quantity: Optional[StrictInt] = None ship_date: Optional[datetime] = Field(default=None, alias="shipDate") - status: Optional[StrictStr] = Field(default=None, description="Order Status") + status: Optional[Literal['placed', 'approved', 'delivered']] = Field( + None, + description="Order Status" + ) complete: Optional[StrictBool] = False additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["id", "petId", "quantity", "shipDate", "status", "complete"] @@ -53,69 +57,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Order from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Order from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "petId": obj.get("petId"), - "quantity": obj.get("quantity"), - "shipDate": obj.get("shipDate"), - "status": obj.get("status"), - "complete": obj.get("complete") if obj.get("complete") is not None else False - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py index 5242660b636b..c137aa6b2f4f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class OuterComposite(BaseModel): """ @@ -39,66 +40,27 @@ class OuterComposite(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OuterComposite from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OuterComposite from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "my_number": obj.get("my_number"), - "my_string": obj.get("my_string"), - "my_boolean": obj.get("my_boolean") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py index f8d215a21c94..bab2f225fba6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py @@ -22,7 +22,8 @@ from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_enum_integer import OuterEnumInteger from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class OuterObjectWithEnumProperty(BaseModel): """ @@ -40,70 +41,27 @@ class OuterObjectWithEnumProperty(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OuterObjectWithEnumProperty from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - # set to None if str_value (nullable) is None - # and model_fields_set contains the field - if self.str_value is None and "str_value" in self.model_fields_set: - _dict['str_value'] = None - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OuterObjectWithEnumProperty from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "str_value": obj.get("str_value"), - "value": obj.get("value") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py index 8a30758ab8fd..ec9d1a338e3b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Parent(BaseModel): """ @@ -38,76 +39,27 @@ class Parent(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Parent from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) - _field_dict = {} - if self.optional_dict: - for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - _dict['optionalDict'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Parent from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "optionalDict": dict( - (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj["optionalDict"].items() - ) - if obj.get("optionalDict") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py index 509693dd1441..1b3a5d2f2f4c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.inner_dict_with_property import InnerDictWithProperty from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ParentWithOptionalDict(BaseModel): """ @@ -38,76 +39,27 @@ class ParentWithOptionalDict(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ParentWithOptionalDict from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) - _field_dict = {} - if self.optional_dict: - for _key_optional_dict in self.optional_dict: - if self.optional_dict[_key_optional_dict]: - _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() - _dict['optionalDict'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ParentWithOptionalDict from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "optionalDict": dict( - (_k, InnerDictWithProperty.from_dict(_v)) - for _k, _v in obj["optionalDict"].items() - ) - if obj.get("optionalDict") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py index 48f0c2fceeb7..0e1a9bf177f2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -23,7 +23,8 @@ from petstore_api.models.category import Category from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Pet(BaseModel): """ @@ -34,7 +35,10 @@ class Pet(BaseModel): name: StrictStr photo_urls: Annotated[List[StrictStr], Field(min_length=0)] = Field(alias="photoUrls") tags: Optional[List[Tag]] = None - status: Optional[StrictStr] = Field(default=None, description="pet status in the store") + status: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["id", "category", "name", "photoUrls", "tags", "status"] @@ -55,79 +59,27 @@ def status_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Pet from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of category - if self.category: - _dict['category'] = self.category.to_dict() - # override the default output from pydantic by calling `to_dict()` of each item in tags (list) - _items = [] - if self.tags: - for _item_tags in self.tags: - if _item_tags: - _items.append(_item_tags.to_dict()) - _dict['tags'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Pet from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "category": Category.from_dict(obj["category"]) if obj.get("category") is not None else None, - "name": obj.get("name"), - "photoUrls": obj.get("photoUrls"), - "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, - "status": obj.get("status") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py index 06798245b8fe..6646e6d477cd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -19,137 +19,55 @@ from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] -class Pig(BaseModel): +class Pig(RootModel[Union[BasquePig, DanishPig]]): """ Pig """ - # data type: BasquePig - oneof_schema_1_validator: Optional[BasquePig] = None - # data type: DanishPig - oneof_schema_2_validator: Optional[DanishPig] = None - actual_instance: Optional[Union[BasquePig, DanishPig]] = None - one_of_schemas: Set[str] = { "BasquePig", "DanishPig" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[BasquePig, DanishPig] = Field( + ..., discriminator="class_name" ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - discriminator_value_class_map: Dict[str, str] = { - } - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = Pig.model_construct() - error_messages = [] - match = 0 - # validate data type: BasquePig - if not isinstance(v, BasquePig): - error_messages.append(f"Error! Input type `{type(v)}` is not `BasquePig`") - else: - match += 1 - # validate data type: DanishPig - if not isinstance(v, DanishPig): - error_messages.append(f"Error! Input type `{type(v)}` is not `DanishPig`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # use oneOf discriminator to lookup the data type - _data_type = json.loads(json_str).get("className") - if not _data_type: - raise ValueError("Failed to lookup data type from the field `className` in the input.") - - # check if data type is `BasquePig` - if _data_type == "BasquePig": - instance.actual_instance = BasquePig.from_json(json_str) - return instance - - # check if data type is `DanishPig` - if _data_type == "DanishPig": - instance.actual_instance = DanishPig.from_json(json_str) - return instance - - # deserialize data into BasquePig - try: - instance.actual_instance = BasquePig.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into DanishPig - try: - instance.actual_instance = DanishPig.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], BasquePig, DanishPig]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py index 74efce9a4d06..f667018ed881 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.type import Type from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PonySizes(BaseModel): """ @@ -38,64 +39,27 @@ class PonySizes(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PonySizes from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PonySizes from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "type": obj.get("type") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py index 76eb72a941bf..7c16bfeec116 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py @@ -20,14 +20,23 @@ from pydantic import BaseModel, ConfigDict, StrictStr, field_validator from typing import Any, ClassVar, Dict, List from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PoopCleaning(BaseModel): """ PoopCleaning """ # noqa: E501 - task_name: StrictStr - function_name: StrictStr + task_name: Literal['cleaning'] = Field( + ..., + description="task_name of the PoopCleaning", + alias="task_name" + ) + function_name: Literal['care'] = Field( + ..., + description="function_name of the PoopCleaning", + alias="function_name" + ) content: StrictStr additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["task_name", "function_name", "content"] @@ -53,66 +62,27 @@ def function_name_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PoopCleaning from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PoopCleaning from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "task_name": obj.get("task_name"), - "function_name": obj.get("function_name"), - "content": obj.get("content") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py index f7a971519f2f..97e03f355280 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.base_discriminator import BaseDiscriminator from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PrimitiveString(BaseDiscriminator): """ @@ -38,65 +39,27 @@ class PrimitiveString(BaseDiscriminator): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PrimitiveString from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PrimitiveString from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_typeName": obj.get("_typeName"), - "_value": obj.get("_value") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py index 0da2a14293de..11bab78a3c96 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.tag import Tag from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PropertyMap(BaseModel): """ @@ -38,76 +39,27 @@ class PropertyMap(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PropertyMap from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) - _field_dict = {} - if self.some_data: - for _key_some_data in self.some_data: - if self.some_data[_key_some_data]: - _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() - _dict['some_data'] = _field_dict - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PropertyMap from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "some_data": dict( - (_k, Tag.from_dict(_v)) - for _k, _v in obj["some_data"].items() - ) - if obj.get("some_data") is not None - else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py index d07aef22cd82..5d0eb8d1225c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class PropertyNameCollision(BaseModel): """ @@ -39,66 +40,27 @@ class PropertyNameCollision(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PropertyNameCollision from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PropertyNameCollision from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_type": obj.get("_type"), - "type": obj.get("type"), - "type_": obj.get("type_") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py index 5a4155fcfa13..3665454efc1d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class ReadOnlyFirst(BaseModel): """ @@ -38,67 +39,27 @@ class ReadOnlyFirst(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReadOnlyFirst from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * OpenAPI `readOnly` fields are excluded. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "bar", - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReadOnlyFirst from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "bar": obj.get("bar"), - "baz": obj.get("baz") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py index 13d6327314c3..b564e6d2ac79 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SecondCircularAllOfRef(BaseModel): """ @@ -38,73 +39,28 @@ class SecondCircularAllOfRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SecondCircularAllOfRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in circular_all_of_ref (list) - _items = [] - if self.circular_all_of_ref: - for _item_circular_all_of_ref in self.circular_all_of_ref: - if _item_circular_all_of_ref: - _items.append(_item_circular_all_of_ref.to_dict()) - _dict['circularAllOfRef'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SecondCircularAllOfRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "_name": obj.get("_name"), - "circularAllOfRef": [CircularAllOfRef.from_dict(_item) for _item in obj["circularAllOfRef"]] if obj.get("circularAllOfRef") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.circular_all_of_ref import CircularAllOfRef # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py index 701e0dccaacf..52d3347704b7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SecondRef(BaseModel): """ @@ -38,69 +39,28 @@ class SecondRef(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SecondRef from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of circular_ref - if self.circular_ref: - _dict['circular_ref'] = self.circular_ref.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SecondRef from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "category": obj.get("category"), - "circular_ref": CircularReferenceModel.from_dict(obj["circular_ref"]) if obj.get("circular_ref") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.circular_reference_model import CircularReferenceModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py index 0273b10dada6..6c11409dee00 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SelfReferenceModel(BaseModel): """ @@ -38,69 +39,28 @@ class SelfReferenceModel(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SelfReferenceModel from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested - if self.nested: - _dict['nested'] = self.nested.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SelfReferenceModel from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested": DummyModel.from_dict(obj["nested"]) if obj.get("nested") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj from petstore_api.models.dummy_model import DummyModel # TODO: Rewrite to not use raise_errors diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py index 84686054875a..ebbf9463952c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SpecialModelName(BaseModel): """ @@ -37,64 +38,27 @@ class SpecialModelName(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SpecialModelName from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SpecialModelName from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "$special[property.name]": obj.get("$special[property.name]") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py index e43761d33dfc..8319ec235809 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.category import Category from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class SpecialName(BaseModel): """ @@ -29,7 +30,10 @@ class SpecialName(BaseModel): """ # noqa: E501 var_property: Optional[StrictInt] = Field(default=None, alias="property") var_async: Optional[Category] = Field(default=None, alias="async") - var_schema: Optional[StrictStr] = Field(default=None, description="pet status in the store", alias="schema") + var_schema: Optional[Literal['available', 'pending', 'sold']] = Field( + None, + description="pet status in the store" + ) additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["property", "async", "schema"] @@ -50,69 +54,27 @@ def var_schema_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of SpecialName from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of var_async - if self.var_async: - _dict['async'] = self.var_async.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of SpecialName from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "property": obj.get("property"), - "async": Category.from_dict(obj["async"]) if obj.get("async") is not None else None, - "schema": obj.get("schema") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py index b3893aecb683..2a95cc94529f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tag(BaseModel): """ @@ -38,65 +39,27 @@ class Tag(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tag from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tag from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task.py b/samples/openapi3/client/petstore/python/petstore_api/models/task.py index a8e0fa11ff84..19ceec24044b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task.py @@ -22,7 +22,8 @@ from uuid import UUID from petstore_api.models.task_activity import TaskActivity from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Task(BaseModel): """ @@ -40,68 +41,27 @@ class Task(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Task from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of activity - if self.activity: - _dict['activity'] = self.activity.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Task from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "activity": TaskActivity.from_dict(obj["activity"]) if obj.get("activity") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py index cc1e1fc5a60f..39a1c0bbc375 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py @@ -20,132 +20,55 @@ from petstore_api.models.bathing import Bathing from petstore_api.models.feeding import Feeding from petstore_api.models.poop_cleaning import PoopCleaning -from pydantic import StrictStr, Field +from pydantic import StrictStr, Field, RootModel from typing import Union, List, Set, Optional, Dict from typing_extensions import Literal, Self TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] -class TaskActivity(BaseModel): +class TaskActivity(RootModel[Union[Bathing, Feeding, PoopCleaning]]): """ TaskActivity """ - # data type: PoopCleaning - oneof_schema_1_validator: Optional[PoopCleaning] = None - # data type: Feeding - oneof_schema_2_validator: Optional[Feeding] = None - # data type: Bathing - oneof_schema_3_validator: Optional[Bathing] = None - actual_instance: Optional[Union[Bathing, Feeding, PoopCleaning]] = None - one_of_schemas: Set[str] = { "Bathing", "Feeding", "PoopCleaning" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), + root: Union[Bathing, Feeding, PoopCleaning] = Field( + ... ) + def __getattr__(self, name): + """ + Delegate attribute access to the root model if the attribute + doesn't exist on the main class. + """ - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): - instance = TaskActivity.model_construct() - error_messages = [] - match = 0 - # validate data type: PoopCleaning - if not isinstance(v, PoopCleaning): - error_messages.append(f"Error! Input type `{type(v)}` is not `PoopCleaning`") - else: - match += 1 - # validate data type: Feeding - if not isinstance(v, Feeding): - error_messages.append(f"Error! Input type `{type(v)}` is not `Feeding`") - else: - match += 1 - # validate data type: Bathing - if not isinstance(v, Bathing): - error_messages.append(f"Error! Input type `{type(v)}` is not `Bathing`") - else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when setting `actual_instance` in TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - else: - return v + if name in self.__dict__: + return super().__getattribute__(name) + + root = self.__dict__.get('root') + if root is not None: + return getattr(root, name) + + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: - return cls.from_json(json.dumps(obj)) + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" - instance = cls.model_construct() - error_messages = [] - match = 0 - - # deserialize data into PoopCleaning - try: - instance.actual_instance = PoopCleaning.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Feeding - try: - instance.actual_instance = Feeding.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Bathing - try: - instance.actual_instance = Bathing.from_json(json_str) - match += 1 - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - elif match == 0: - # no match - raise ValueError("No match found when deserializing the JSON string into TaskActivity with oneOf schemas: Bathing, Feeding, PoopCleaning. Details: " + ", ".join(error_messages)) - else: - return instance + return cls.model_validate_json(json_str) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" + return self.model_dump_json(by_alias=True, exclude_none=True) - if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> Optional[Union[Dict[str, Any], Bathing, Feeding, PoopCleaning]]: + def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return None - - if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance + return self.model_dump(by_alias=True) def to_str(self) -> str: """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump()) + return pprint.pformat(self.model_dump(by_alias=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py index f5fe068c9111..1afe35f8f1ef 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestErrorResponsesWithModel400Response(BaseModel): """ @@ -37,64 +38,27 @@ class TestErrorResponsesWithModel400Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel400Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "reason400": obj.get("reason400") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py index 39e6c512ed3e..91ea69de6d18 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestErrorResponsesWithModel404Response(BaseModel): """ @@ -37,64 +38,27 @@ class TestErrorResponsesWithModel404Response(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestErrorResponsesWithModel404Response from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "reason404": obj.get("reason404") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py index 7b93d84864f2..b8ae3f003698 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): """ @@ -37,64 +38,27 @@ class TestInlineFreeformAdditionalPropertiesRequest(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestInlineFreeformAdditionalPropertiesRequest from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "someProperty": obj.get("someProperty") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py index 4bff5e699a37..b239642e7959 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py @@ -22,7 +22,8 @@ from petstore_api.models.test_enum import TestEnum from petstore_api.models.test_enum_with_default import TestEnumWithDefault from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestModelWithEnumDefault(BaseModel): """ @@ -32,7 +33,10 @@ class TestModelWithEnumDefault(BaseModel): test_string: Optional[StrictStr] = None test_enum_with_default: Optional[TestEnumWithDefault] = TestEnumWithDefault.ZWEI test_string_with_default: Optional[StrictStr] = 'ahoy matey' - test_inline_defined_enum_with_default: Optional[StrictStr] = 'B' + test_inline_defined_enum_with_default: Optional[Literal['A', 'B', 'C']] = Field( + None, + description="test_inline_defined_enum_with_default of the TestModelWithEnumDefault" + ) additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["test_enum", "test_string", "test_enum_with_default", "test_string_with_default", "test_inline_defined_enum_with_default"] @@ -53,68 +57,27 @@ def test_inline_defined_enum_with_default_validate_enum(cls, value): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestModelWithEnumDefault from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestModelWithEnumDefault from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "test_enum": obj.get("test_enum"), - "test_string": obj.get("test_string"), - "test_enum_with_default": obj.get("test_enum_with_default") if obj.get("test_enum_with_default") is not None else TestEnumWithDefault.ZWEI, - "test_string_with_default": obj.get("test_string_with_default") if obj.get("test_string_with_default") is not None else 'ahoy matey', - "test_inline_defined_enum_with_default": obj.get("test_inline_defined_enum_with_default") if obj.get("test_inline_defined_enum_with_default") is not None else 'B' - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py index c31d72482d59..dbdf41c24874 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class TestObjectForMultipartRequestsRequestMarker(BaseModel): """ @@ -37,64 +38,27 @@ class TestObjectForMultipartRequestsRequestMarker(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of TestObjectForMultipartRequestsRequestMarker from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of TestObjectForMultipartRequestsRequestMarker from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py index c2dab004fe1a..17d63717565f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class Tiger(BaseModel): """ @@ -37,64 +38,27 @@ class Tiger(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Tiger from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Tiger from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "skill": obj.get("skill") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index e5b5cb4ddeda..7e665d3a2739 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -21,7 +21,8 @@ from typing import Any, ClassVar, Dict, List, Optional from petstore_api.models.creature_info import CreatureInfo from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UnnamedDictWithAdditionalModelListProperties(BaseModel): """ @@ -38,80 +39,27 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalModelListProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) - _field_dict_of_array = {} - if self.dict_property: - for _key_dict_property in self.dict_property: - if self.dict_property[_key_dict_property] is not None: - _field_dict_of_array[_key_dict_property] = [ - _item.to_dict() for _item in self.dict_property[_key_dict_property] - ] - _dict['dictProperty'] = _field_dict_of_array - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalModelListProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "dictProperty": dict( - (_k, - [CreatureInfo.from_dict(_item) for _item in _v] - if _v is not None - else None - ) - for _k, _v in obj.get("dictProperty", {}).items() - ) - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index f4c7625325c8..863584646440 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UnnamedDictWithAdditionalStringListProperties(BaseModel): """ @@ -37,64 +38,27 @@ class UnnamedDictWithAdditionalStringListProperties(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalStringListProperties from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UnnamedDictWithAdditionalStringListProperties from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "dictProperty": obj.get("dictProperty") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py index 6d79131bfe79..466d550ec22c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class UploadFileWithAdditionalPropertiesRequestObject(BaseModel): """ @@ -37,64 +38,27 @@ class UploadFileWithAdditionalPropertiesRequestObject(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of UploadFileWithAdditionalPropertiesRequestObject from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of UploadFileWithAdditionalPropertiesRequestObject from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/user.py b/samples/openapi3/client/petstore/python/petstore_api/models/user.py index ceeb6d4ae54c..b47a215064eb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/user.py @@ -20,7 +20,8 @@ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class User(BaseModel): """ @@ -44,71 +45,27 @@ class User(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of User from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of User from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "id": obj.get("id"), - "username": obj.get("username"), - "firstName": obj.get("firstName"), - "lastName": obj.get("lastName"), - "email": obj.get("email"), - "password": obj.get("password"), - "phone": obj.get("phone"), - "userStatus": obj.get("userStatus") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py index eb7e90879e90..c4da6d5004c5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py @@ -22,7 +22,8 @@ from petstore_api.models.one_of_enum_string import OneOfEnumString from petstore_api.models.pig import Pig from typing import Optional, Set -from typing_extensions import Self +from typing_extensions import Self, Literal +from pydantic import Field class WithNestedOneOf(BaseModel): """ @@ -41,72 +42,27 @@ class WithNestedOneOf(BaseModel): ) - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of WithNestedOneOf from a JSON string""" - return cls.from_dict(json.loads(json_str)) + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of nested_pig - if self.nested_pig: - _dict['nested_pig'] = self.nested_pig.to_dict() - # override the default output from pydantic by calling `to_dict()` of nested_oneof_enum_string - if self.nested_oneof_enum_string: - _dict['nested_oneof_enum_string'] = self.nested_oneof_enum_string.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of WithNestedOneOf from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "size": obj.get("size"), - "nested_pig": Pig.from_dict(obj["nested_pig"]) if obj.get("nested_pig") is not None else None, - "nested_oneof_enum_string": OneOfEnumString.from_dict(obj["nested_oneof_enum_string"]) if obj.get("nested_oneof_enum_string") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj diff --git a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-3.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-3.1/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs index e69de29bb2d1..97ae99c9295a 100644 --- a/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs +++ b/samples/server/petstore/aspnetcore-5.0/src/Org.OpenAPITools/Filters/BasePathFilter.cs @@ -0,0 +1,60 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.Linq; +using System.Text.RegularExpressions; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// BasePath Document Filter sets BasePath property of OpenAPI and removes it from the individual URL paths + /// + public class BasePathFilter : IDocumentFilter + { + /// + /// Constructor + /// + /// BasePath to remove from Operations + public BasePathFilter(string basePath) + { + BasePath = basePath; + } + + /// + /// Gets the BasePath of the OpenAPI Doc + /// + /// The BasePath of the OpenAPI Doc + public string BasePath { get; } + + /// + /// Apply the filter + /// + /// OpenApiDocument + /// FilterContext + public void Apply(OpenApiDocument openapiDoc, DocumentFilterContext context) + { + //openapiDoc.BasePath = BasePath; + + var pathsToModify = openapiDoc.Paths.Where(p => p.Key.StartsWith(BasePath)).ToList(); + + foreach (var (key, value) in pathsToModify) + { + if (key.StartsWith(BasePath)) + { + var newKey = Regex.Replace(key, $"^{BasePath}", string.Empty); + openapiDoc.Paths.Remove(key); + openapiDoc.Paths.Add(newKey, value); + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-6.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-6.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-6.0-pocoModels/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json index e69de29bb2d1..b47dce3d2c68 100644 --- a/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json +++ b/samples/server/petstore/aspnetcore-6.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -0,0 +1,1203 @@ +{ + "openapi" : "3.0.0", + "info" : { + "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + "license" : { + "name" : "Apache-2.0", + "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title" : "OpenAPI Petstore", + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "description" : "Everything about your Pets", + "name" : "pet" + }, { + "description" : "Access to Petstore orders", + "name" : "store" + }, { + "description" : "Operations about user", + "name" : "user" + } ], + "paths" : { + "/test" : { + "get" : { + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "testQuery", + "required" : false, + "schema" : { + "$ref" : "#/components/schemas/TestEnum" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "description" : "OK" + } + }, + "summary" : "Test API" + } + }, + "/pet" : { + "post" : { + "description" : "", + "operationId" : "addPet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ] + }, + "put" : { + "description" : "", + "operationId" : "updatePet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + }, + "405" : { + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ] + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "deprecated" : true, + "description" : "Status values that need to be considered for filter", + "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, + "schema" : { + "items" : { + "default" : "available", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] + } + }, + "/pet/findByTags" : { + "get" : { + "deprecated" : true, + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "description" : "Tags to filter by", + "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, + "schema" : { + "items" : { + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}" : { + "delete" : { + "description" : "", + "operationId" : "deletePet", + "parameters" : [ { + "explode" : false, + "in" : "header", + "name" : "api_key", + "required" : false, + "schema" : { + "type" : "string" + }, + "style" : "simple" + }, { + "description" : "Pet id to delete", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, + "get" : { + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "description" : "ID of pet to return", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] + }, + "post" : { + "description" : "", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "description" : "ID of pet that needs to be updated", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "$ref" : "#/components/schemas/updatePetWithForm_request" + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "description" : "", + "operationId" : "uploadFile", + "parameters" : [ { + "description" : "ID of pet to update", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "$ref" : "#/components/schemas/uploadFile_request" + } + } + } + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] + } + }, + "/store/inventory" : { + "get" : { + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "additionalProperties" : { + "format" : "int32", + "type" : "integer" + }, + "type" : "object" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] + } + }, + "/store/order" : { + "post" : { + "description" : "", + "operationId" : "placeOrder", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "order placed for purchasing the pet", + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid Order" + } + }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ] + } + }, + "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, + "get" : { + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "description" : "ID of pet that needs to be fetched", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "format" : "int64", + "maximum" : 5, + "minimum" : 1, + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] + } + }, + "/user" : { + "post" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Created user object", + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Create user", + "tags" : [ "user" ] + } + }, + "/user/createWithArray" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/createWithList" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/login" : { + "get" : { + "description" : "", + "operationId" : "loginUser", + "parameters" : [ { + "description" : "The user name for login", + "explode" : true, + "in" : "query", + "name" : "username", + "required" : true, + "schema" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + }, + "style" : "form" + }, { + "description" : "The password for login in clear text", + "explode" : true, + "in" : "query", + "name" : "password", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + }, + "description" : "successful operation", + "headers" : { + "Set-Cookie" : { + "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", + "explode" : false, + "schema" : { + "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", + "type" : "string" + }, + "style" : "simple" + }, + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "explode" : false, + "schema" : { + "format" : "int32", + "type" : "integer" + }, + "style" : "simple" + }, + "X-Expires-After" : { + "description" : "date in UTC when token expires", + "explode" : false, + "schema" : { + "format" : "date-time", + "type" : "string" + }, + "style" : "simple" + } + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] + } + }, + "/user/logout" : { + "get" : { + "description" : "", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] + } + }, + "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Delete user", + "tags" : [ "user" ] + }, + "get" : { + "description" : "", + "operationId" : "getUserByName", + "parameters" : [ { + "description" : "The name that needs to be fetched. Use user1 for testing.", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] + }, + "put" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "description" : "name that need to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Updated user object", + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Updated user", + "tags" : [ "user" ] + } + }, + "/fake/parameter_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_parameter_example_test", + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "data", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/Pet" + }, + "style" : "form" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "summary" : "fake endpoint to test parameter example (object)", + "tags" : [ "fake" ] + } + }, + "/fake/nullable_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_nullable_example_test", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TestNullable" + } + } + }, + "description" : "Successful operation" + } + }, + "summary" : "Fake endpoint to test nullable example (object)", + "tags" : [ "fake" ] + } + } + }, + "components" : { + "requestBodies" : { + "UserArray" : { + "content" : { + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "Pet" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + } + }, + "schemas" : { + "TestEnum" : { + "enum" : [ "A", "B" ], + "type" : "string" + }, + "TestNullable" : { + "example" : { + "nullableName" : "nullableName", + "name" : "name" + }, + "properties" : { + "name" : { + "type" : "string" + }, + "nullableName" : { + "nullable" : true, + "type" : "string" + } + }, + "type" : "object" + }, + "Order" : { + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "petId" : { + "format" : "int64", + "type" : "integer" + }, + "quantity" : { + "format" : "int32", + "type" : "integer" + }, + "shipDate" : { + "format" : "date-time", + "type" : "string" + }, + "status" : { + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" + }, + "complete" : { + "default" : false, + "type" : "boolean" + } + }, + "title" : "Pet Order", + "type" : "object", + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "description" : "User Status", + "format" : "int32", + "type" : "integer" + } + }, + "title" : "a User", + "type" : "object", + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet Tag", + "type" : "object", + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "example" : "doggie", + "type" : "string" + }, + "photoUrls" : { + "items" : { + "type" : "string" + }, + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + } + }, + "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + } + }, + "status" : { + "deprecated" : true, + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + } + }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "breed" : { + "type" : "string" + } + }, + "type" : "object" + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "declawed" : { + "type" : "boolean" + } + }, + "type" : "object" + } ] + }, + "Animal" : { + "discriminator" : { + "mapping" : { + "DOG" : "#/components/schemas/Dog", + "CAT" : "#/components/schemas/Cat" + }, + "propertyName" : "className" + }, + "properties" : { + "className" : { + "type" : "string" + }, + "color" : { + "default" : "red", + "type" : "string" + } + }, + "required" : [ "className" ], + "type" : "object" + }, + "updatePetWithForm_request" : { + "properties" : { + "name" : { + "description" : "Updated name of the pet", + "type" : "string" + }, + "status" : { + "description" : "Updated status of the pet", + "type" : "string" + } + }, + "type" : "object" + }, + "uploadFile_request" : { + "properties" : { + "additionalMetadata" : { + "description" : "Additional data to pass to server", + "type" : "string" + }, + "file" : { + "description" : "file to upload", + "format" : "binary", + "type" : "string" + } + }, + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_auth" : { + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "type" : "oauth2" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-6.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-8.0-NewtonsoftFalse/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-8.0-nullableReferenceTypes/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json index e69de29bb2d1..b47dce3d2c68 100644 --- a/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json +++ b/samples/server/petstore/aspnetcore-8.0-pocoModels/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -0,0 +1,1203 @@ +{ + "openapi" : "3.0.0", + "info" : { + "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + "license" : { + "name" : "Apache-2.0", + "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title" : "OpenAPI Petstore", + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "description" : "Everything about your Pets", + "name" : "pet" + }, { + "description" : "Access to Petstore orders", + "name" : "store" + }, { + "description" : "Operations about user", + "name" : "user" + } ], + "paths" : { + "/test" : { + "get" : { + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "testQuery", + "required" : false, + "schema" : { + "$ref" : "#/components/schemas/TestEnum" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "description" : "OK" + } + }, + "summary" : "Test API" + } + }, + "/pet" : { + "post" : { + "description" : "", + "operationId" : "addPet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ] + }, + "put" : { + "description" : "", + "operationId" : "updatePet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + }, + "405" : { + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ] + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "deprecated" : true, + "description" : "Status values that need to be considered for filter", + "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, + "schema" : { + "items" : { + "default" : "available", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] + } + }, + "/pet/findByTags" : { + "get" : { + "deprecated" : true, + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "description" : "Tags to filter by", + "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, + "schema" : { + "items" : { + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}" : { + "delete" : { + "description" : "", + "operationId" : "deletePet", + "parameters" : [ { + "explode" : false, + "in" : "header", + "name" : "api_key", + "required" : false, + "schema" : { + "type" : "string" + }, + "style" : "simple" + }, { + "description" : "Pet id to delete", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, + "get" : { + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "description" : "ID of pet to return", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] + }, + "post" : { + "description" : "", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "description" : "ID of pet that needs to be updated", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "$ref" : "#/components/schemas/updatePetWithForm_request" + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "description" : "", + "operationId" : "uploadFile", + "parameters" : [ { + "description" : "ID of pet to update", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "$ref" : "#/components/schemas/uploadFile_request" + } + } + } + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] + } + }, + "/store/inventory" : { + "get" : { + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "additionalProperties" : { + "format" : "int32", + "type" : "integer" + }, + "type" : "object" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] + } + }, + "/store/order" : { + "post" : { + "description" : "", + "operationId" : "placeOrder", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "order placed for purchasing the pet", + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid Order" + } + }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ] + } + }, + "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, + "get" : { + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "description" : "ID of pet that needs to be fetched", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "format" : "int64", + "maximum" : 5, + "minimum" : 1, + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] + } + }, + "/user" : { + "post" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Created user object", + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Create user", + "tags" : [ "user" ] + } + }, + "/user/createWithArray" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/createWithList" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/login" : { + "get" : { + "description" : "", + "operationId" : "loginUser", + "parameters" : [ { + "description" : "The user name for login", + "explode" : true, + "in" : "query", + "name" : "username", + "required" : true, + "schema" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + }, + "style" : "form" + }, { + "description" : "The password for login in clear text", + "explode" : true, + "in" : "query", + "name" : "password", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + }, + "description" : "successful operation", + "headers" : { + "Set-Cookie" : { + "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", + "explode" : false, + "schema" : { + "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", + "type" : "string" + }, + "style" : "simple" + }, + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "explode" : false, + "schema" : { + "format" : "int32", + "type" : "integer" + }, + "style" : "simple" + }, + "X-Expires-After" : { + "description" : "date in UTC when token expires", + "explode" : false, + "schema" : { + "format" : "date-time", + "type" : "string" + }, + "style" : "simple" + } + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] + } + }, + "/user/logout" : { + "get" : { + "description" : "", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] + } + }, + "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Delete user", + "tags" : [ "user" ] + }, + "get" : { + "description" : "", + "operationId" : "getUserByName", + "parameters" : [ { + "description" : "The name that needs to be fetched. Use user1 for testing.", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] + }, + "put" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "description" : "name that need to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Updated user object", + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Updated user", + "tags" : [ "user" ] + } + }, + "/fake/parameter_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_parameter_example_test", + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "data", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/Pet" + }, + "style" : "form" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "summary" : "fake endpoint to test parameter example (object)", + "tags" : [ "fake" ] + } + }, + "/fake/nullable_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_nullable_example_test", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TestNullable" + } + } + }, + "description" : "Successful operation" + } + }, + "summary" : "Fake endpoint to test nullable example (object)", + "tags" : [ "fake" ] + } + } + }, + "components" : { + "requestBodies" : { + "UserArray" : { + "content" : { + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "Pet" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + } + }, + "schemas" : { + "TestEnum" : { + "enum" : [ "A", "B" ], + "type" : "string" + }, + "TestNullable" : { + "example" : { + "nullableName" : "nullableName", + "name" : "name" + }, + "properties" : { + "name" : { + "type" : "string" + }, + "nullableName" : { + "nullable" : true, + "type" : "string" + } + }, + "type" : "object" + }, + "Order" : { + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "petId" : { + "format" : "int64", + "type" : "integer" + }, + "quantity" : { + "format" : "int32", + "type" : "integer" + }, + "shipDate" : { + "format" : "date-time", + "type" : "string" + }, + "status" : { + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" + }, + "complete" : { + "default" : false, + "type" : "boolean" + } + }, + "title" : "Pet Order", + "type" : "object", + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "description" : "User Status", + "format" : "int32", + "type" : "integer" + } + }, + "title" : "a User", + "type" : "object", + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet Tag", + "type" : "object", + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "example" : "doggie", + "type" : "string" + }, + "photoUrls" : { + "items" : { + "type" : "string" + }, + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + } + }, + "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + } + }, + "status" : { + "deprecated" : true, + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + } + }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "breed" : { + "type" : "string" + } + }, + "type" : "object" + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "declawed" : { + "type" : "boolean" + } + }, + "type" : "object" + } ] + }, + "Animal" : { + "discriminator" : { + "mapping" : { + "DOG" : "#/components/schemas/Dog", + "CAT" : "#/components/schemas/Cat" + }, + "propertyName" : "className" + }, + "properties" : { + "className" : { + "type" : "string" + }, + "color" : { + "default" : "red", + "type" : "string" + } + }, + "required" : [ "className" ], + "type" : "object" + }, + "updatePetWithForm_request" : { + "properties" : { + "name" : { + "description" : "Updated name of the pet", + "type" : "string" + }, + "status" : { + "description" : "Updated status of the pet", + "type" : "string" + } + }, + "type" : "object" + }, + "uploadFile_request" : { + "properties" : { + "additionalMetadata" : { + "description" : "Additional data to pass to server", + "type" : "string" + }, + "file" : { + "description" : "file to upload", + "format" : "binary", + "type" : "string" + } + }, + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_auth" : { + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "type" : "oauth2" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json index e69de29bb2d1..b47dce3d2c68 100644 --- a/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json +++ b/samples/server/petstore/aspnetcore-8.0-project4Models/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -0,0 +1,1203 @@ +{ + "openapi" : "3.0.0", + "info" : { + "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + "license" : { + "name" : "Apache-2.0", + "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title" : "OpenAPI Petstore", + "version" : "1.0.0" + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "description" : "Everything about your Pets", + "name" : "pet" + }, { + "description" : "Access to Petstore orders", + "name" : "store" + }, { + "description" : "Operations about user", + "name" : "user" + } ], + "paths" : { + "/test" : { + "get" : { + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "testQuery", + "required" : false, + "schema" : { + "$ref" : "#/components/schemas/TestEnum" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "description" : "OK" + } + }, + "summary" : "Test API" + } + }, + "/pet" : { + "post" : { + "description" : "", + "operationId" : "addPet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ] + }, + "put" : { + "description" : "", + "operationId" : "updatePet", + "requestBody" : { + "$ref" : "#/components/requestBodies/Pet" + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + }, + "405" : { + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ] + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "deprecated" : true, + "description" : "Status values that need to be considered for filter", + "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, + "schema" : { + "items" : { + "default" : "available", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] + } + }, + "/pet/findByTags" : { + "get" : { + "deprecated" : true, + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "description" : "Tags to filter by", + "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, + "schema" : { + "items" : { + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "read:pets" ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}" : { + "delete" : { + "description" : "", + "operationId" : "deletePet", + "parameters" : [ { + "explode" : false, + "in" : "header", + "name" : "api_key", + "required" : false, + "schema" : { + "type" : "string" + }, + "style" : "simple" + }, { + "description" : "Pet id to delete", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, + "get" : { + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "description" : "ID of pet to return", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Pet not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] + }, + "post" : { + "description" : "", + "operationId" : "updatePetWithForm", + "parameters" : [ { + "description" : "ID of pet that needs to be updated", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "$ref" : "#/components/schemas/updatePetWithForm_request" + } + } + } + }, + "responses" : { + "405" : { + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "description" : "", + "operationId" : "uploadFile", + "parameters" : [ { + "description" : "ID of pet to update", + "explode" : false, + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "$ref" : "#/components/schemas/uploadFile_request" + } + } + } + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] + } + }, + "/store/inventory" : { + "get" : { + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "additionalProperties" : { + "format" : "int32", + "type" : "integer" + }, + "type" : "object" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] + } + }, + "/store/order" : { + "post" : { + "description" : "", + "operationId" : "placeOrder", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "order placed for purchasing the pet", + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid Order" + } + }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ] + } + }, + "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, + "get" : { + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "description" : "ID of pet that needs to be fetched", + "explode" : false, + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "format" : "int64", + "maximum" : 5, + "minimum" : 1, + "type" : "integer" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid ID supplied" + }, + "404" : { + "description" : "Order not found" + } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] + } + }, + "/user" : { + "post" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Created user object", + "required" : true + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Create user", + "tags" : [ "user" ] + } + }, + "/user/createWithArray" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/createWithList" : { + "post" : { + "description" : "", + "operationId" : "createUsersWithListInput", + "requestBody" : { + "$ref" : "#/components/requestBodies/UserArray" + }, + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ] + } + }, + "/user/login" : { + "get" : { + "description" : "", + "operationId" : "loginUser", + "parameters" : [ { + "description" : "The user name for login", + "explode" : true, + "in" : "query", + "name" : "username", + "required" : true, + "schema" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + }, + "style" : "form" + }, { + "description" : "The password for login in clear text", + "explode" : true, + "in" : "query", + "name" : "password", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + }, + "description" : "successful operation", + "headers" : { + "Set-Cookie" : { + "description" : "Cookie authentication key for use with the `api_key` apiKey authentication.", + "explode" : false, + "schema" : { + "example" : "AUTH_KEY=abcde12345; Path=/; HttpOnly", + "type" : "string" + }, + "style" : "simple" + }, + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "explode" : false, + "schema" : { + "format" : "int32", + "type" : "integer" + }, + "style" : "simple" + }, + "X-Expires-After" : { + "description" : "date in UTC when token expires", + "explode" : false, + "schema" : { + "format" : "date-time", + "type" : "string" + }, + "style" : "simple" + } + } + }, + "400" : { + "description" : "Invalid username/password supplied" + } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] + } + }, + "/user/logout" : { + "get" : { + "description" : "", + "operationId" : "logoutUser", + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] + } + }, + "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Delete user", + "tags" : [ "user" ] + }, + "get" : { + "description" : "", + "operationId" : "getUserByName", + "parameters" : [ { + "description" : "The name that needs to be fetched. Use user1 for testing.", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] + }, + "put" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "description" : "name that need to be deleted", + "explode" : false, + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + }, + "style" : "simple" + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Updated user object", + "required" : true + }, + "responses" : { + "400" : { + "description" : "Invalid user supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Updated user", + "tags" : [ "user" ] + } + }, + "/fake/parameter_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_parameter_example_test", + "parameters" : [ { + "explode" : true, + "in" : "query", + "name" : "data", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/Pet" + }, + "style" : "form" + } ], + "responses" : { + "default" : { + "description" : "successful operation" + } + }, + "summary" : "fake endpoint to test parameter example (object)", + "tags" : [ "fake" ] + } + }, + "/fake/nullable_example_test" : { + "get" : { + "description" : "", + "operationId" : "fake_nullable_example_test", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/TestNullable" + } + } + }, + "description" : "Successful operation" + } + }, + "summary" : "Fake endpoint to test nullable example (object)", + "tags" : [ "fake" ] + } + } + }, + "components" : { + "requestBodies" : { + "UserArray" : { + "content" : { + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "Pet" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + } + }, + "schemas" : { + "TestEnum" : { + "enum" : [ "A", "B" ], + "type" : "string" + }, + "TestNullable" : { + "example" : { + "nullableName" : "nullableName", + "name" : "name" + }, + "properties" : { + "name" : { + "type" : "string" + }, + "nullableName" : { + "nullable" : true, + "type" : "string" + } + }, + "type" : "object" + }, + "Order" : { + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "petId" : { + "format" : "int64", + "type" : "integer" + }, + "quantity" : { + "format" : "int32", + "type" : "integer" + }, + "shipDate" : { + "format" : "date-time", + "type" : "string" + }, + "status" : { + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" + }, + "complete" : { + "default" : false, + "type" : "boolean" + } + }, + "title" : "Pet Order", + "type" : "object", + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "pattern" : "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$", + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "description" : "User Status", + "format" : "int32", + "type" : "integer" + } + }, + "title" : "a User", + "type" : "object", + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet Tag", + "type" : "object", + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "example" : "doggie", + "type" : "string" + }, + "photoUrls" : { + "items" : { + "type" : "string" + }, + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + } + }, + "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + } + }, + "status" : { + "deprecated" : true, + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + } + }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "breed" : { + "type" : "string" + } + }, + "type" : "object" + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/components/schemas/Animal" + }, { + "properties" : { + "declawed" : { + "type" : "boolean" + } + }, + "type" : "object" + } ] + }, + "Animal" : { + "discriminator" : { + "mapping" : { + "DOG" : "#/components/schemas/Dog", + "CAT" : "#/components/schemas/Cat" + }, + "propertyName" : "className" + }, + "properties" : { + "className" : { + "type" : "string" + }, + "color" : { + "default" : "red", + "type" : "string" + } + }, + "required" : [ "className" ], + "type" : "object" + }, + "updatePetWithForm_request" : { + "properties" : { + "name" : { + "description" : "Updated name of the pet", + "type" : "string" + }, + "status" : { + "description" : "Updated status of the pet", + "type" : "string" + } + }, + "type" : "object" + }, + "uploadFile_request" : { + "properties" : { + "additionalMetadata" : { + "description" : "Additional data to pass to server", + "type" : "string" + }, + "file" : { + "description" : "file to upload", + "format" : "binary", + "type" : "string" + } + }, + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_auth" : { + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "type" : "oauth2" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-8.0-use-centralized-package-version-management/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs index e69de29bb2d1..9eccd5c317f6 100644 --- a/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs +++ b/samples/server/petstore/aspnetcore-8.0/src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,107 @@ +/* + * OpenAPI Petstore + * + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace Org.OpenAPITools.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var openapiParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes.ToList(); + + // See https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1147 + // and https://mikeralphson.github.io/openapi/2017/03/15/openapi3.0.0-rc0 + // Basically OpenAPI v3 body parameters are split out into RequestBody and the properties have moved to schema + if (attributes.Any() && openapiParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + openapiParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + var regex = (string)regexAttr.ConstructorArguments[0].Value; + openapiParam.Schema.Pattern = regex; + } + + // String Length [StringLength] + int? minLength = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLength = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLength = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (minLength != null) + { + openapiParam.Schema.MinLength = minLength; + } + + if (maxLength != null) + { + openapiParam.Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + var rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + var rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + openapiParam.Schema.MinLength = rangeMin; + openapiParam.Schema.MaxLength = rangeMax; + } + } + } + } + } +} diff --git a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json index e69de29bb2d1..333dcf2bfceb 100644 --- a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json +++ b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/wwwroot/openapi-original.json @@ -0,0 +1,1021 @@ +{ + "openapi" : "3.0.1", + "info" : { + "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", + "license" : { + "name" : "Apache-2.0", + "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title" : "OpenAPI Petstore", + "version" : "1.0.0" + }, + "servers" : [ { + "url" : "http://petstore.swagger.io/v2" + } ], + "tags" : [ { + "description" : "Everything about your Pets", + "name" : "pet" + }, { + "description" : "Access to Petstore orders", + "name" : "store" + }, { + "description" : "Operations about user", + "name" : "user" + } ], + "paths" : { + "/pet" : { + "post" : { + "operationId" : "addPet", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + }, + "responses" : { + "405" : { + "content" : { }, + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ], + "x-codegen-request-body-name" : "body" + }, + "put" : { + "operationId" : "updatePet", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "Pet object that needs to be added to the store", + "required" : true + }, + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid ID supplied" + }, + "404" : { + "content" : { }, + "description" : "Pet not found" + }, + "405" : { + "content" : { }, + "description" : "Validation exception" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ], + "x-codegen-request-body-name" : "body" + } + }, + "/pet/findByStatus" : { + "get" : { + "description" : "Multiple status values can be provided with comma separated strings", + "operationId" : "findPetsByStatus", + "parameters" : [ { + "description" : "Status values that need to be considered for filter", + "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, + "schema" : { + "items" : { + "default" : "available", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "content" : { }, + "description" : "Invalid status value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] + } + }, + "/pet/findByTags" : { + "get" : { + "deprecated" : true, + "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId" : "findPetsByTags", + "parameters" : [ { + "description" : "Tags to filter by", + "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, + "schema" : { + "items" : { + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + }, + "application/json" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/Pet" + }, + "type" : "array" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "content" : { }, + "description" : "Invalid tag value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}" : { + "delete" : { + "operationId" : "deletePet", + "parameters" : [ { + "in" : "header", + "name" : "api_key", + "schema" : { + "type" : "string" + } + }, { + "description" : "Pet id to delete", + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + } + } ], + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, + "get" : { + "description" : "Returns a single pet", + "operationId" : "getPetById", + "parameters" : [ { + "description" : "ID of pet to return", + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + } + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Pet" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "content" : { }, + "description" : "Invalid ID supplied" + }, + "404" : { + "content" : { }, + "description" : "Pet not found" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] + }, + "post" : { + "operationId" : "updatePetWithForm", + "parameters" : [ { + "description" : "ID of pet that needs to be updated", + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + } + } ], + "requestBody" : { + "content" : { + "application/x-www-form-urlencoded" : { + "schema" : { + "$ref" : "#/components/schemas/updatePetWithForm_request" + } + } + } + }, + "responses" : { + "405" : { + "content" : { }, + "description" : "Invalid input" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] + } + }, + "/pet/{petId}/uploadImage" : { + "post" : { + "operationId" : "uploadFile", + "parameters" : [ { + "description" : "ID of pet to update", + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + } + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "$ref" : "#/components/schemas/uploadFile_request" + } + } + } + }, + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/ApiResponse" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] + } + }, + "/store/inventory" : { + "get" : { + "description" : "Returns a map of status codes to quantities", + "operationId" : "getInventory", + "responses" : { + "200" : { + "content" : { + "application/json" : { + "schema" : { + "additionalProperties" : { + "format" : "int32", + "type" : "integer" + }, + "type" : "object" + } + } + }, + "description" : "successful operation" + } + }, + "security" : [ { + "api_key" : [ ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] + } + }, + "/store/order" : { + "post" : { + "operationId" : "placeOrder", + "requestBody" : { + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "order placed for purchasing the pet", + "required" : true + }, + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "content" : { }, + "description" : "Invalid Order" + } + }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ], + "x-codegen-request-body-name" : "body" + } + }, + "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid ID supplied" + }, + "404" : { + "content" : { }, + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, + "get" : { + "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions", + "operationId" : "getOrderById", + "parameters" : [ { + "description" : "ID of pet that needs to be fetched", + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "format" : "int64", + "maximum" : 5, + "minimum" : 1, + "type" : "integer" + } + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/Order" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "content" : { }, + "description" : "Invalid ID supplied" + }, + "404" : { + "content" : { }, + "description" : "Order not found" + } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] + } + }, + "/user" : { + "post" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "createUser", + "requestBody" : { + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Created user object", + "required" : true + }, + "responses" : { + "default" : { + "content" : { }, + "description" : "successful operation" + } + }, + "summary" : "Create user", + "tags" : [ "user" ], + "x-codegen-request-body-name" : "body" + } + }, + "/user/createWithArray" : { + "post" : { + "operationId" : "createUsersWithArrayInput", + "requestBody" : { + "content" : { + "*/*" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "responses" : { + "default" : { + "content" : { }, + "description" : "successful operation" + } + }, + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ], + "x-codegen-request-body-name" : "body" + } + }, + "/user/createWithList" : { + "post" : { + "operationId" : "createUsersWithListInput", + "requestBody" : { + "content" : { + "*/*" : { + "schema" : { + "items" : { + "$ref" : "#/components/schemas/User" + }, + "type" : "array" + } + } + }, + "description" : "List of user object", + "required" : true + }, + "responses" : { + "default" : { + "content" : { }, + "description" : "successful operation" + } + }, + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ], + "x-codegen-request-body-name" : "body" + } + }, + "/user/login" : { + "get" : { + "operationId" : "loginUser", + "parameters" : [ { + "description" : "The user name for login", + "in" : "query", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "description" : "The password for login in clear text", + "in" : "query", + "name" : "password", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "type" : "string" + } + }, + "application/json" : { + "schema" : { + "type" : "string" + } + } + }, + "description" : "successful operation", + "headers" : { + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", + "schema" : { + "format" : "int32", + "type" : "integer" + } + }, + "X-Expires-After" : { + "description" : "date in UTC when token expires", + "schema" : { + "format" : "date-time", + "type" : "string" + } + } + } + }, + "400" : { + "content" : { }, + "description" : "Invalid username/password supplied" + } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] + } + }, + "/user/logout" : { + "get" : { + "operationId" : "logoutUser", + "responses" : { + "default" : { + "content" : { }, + "description" : "successful operation" + } + }, + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] + } + }, + "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid username supplied" + }, + "404" : { + "content" : { }, + "description" : "User not found" + } + }, + "summary" : "Delete user", + "tags" : [ "user" ] + }, + "get" : { + "operationId" : "getUserByName", + "parameters" : [ { + "description" : "The name that needs to be fetched. Use user1 for testing.", + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "content" : { + "application/xml" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + }, + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "successful operation" + }, + "400" : { + "content" : { }, + "description" : "Invalid username supplied" + }, + "404" : { + "content" : { }, + "description" : "User not found" + } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] + }, + "put" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "updateUser", + "parameters" : [ { + "description" : "name that need to be deleted", + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "*/*" : { + "schema" : { + "$ref" : "#/components/schemas/User" + } + } + }, + "description" : "Updated user object", + "required" : true + }, + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid user supplied" + }, + "404" : { + "content" : { }, + "description" : "User not found" + } + }, + "summary" : "Updated user", + "tags" : [ "user" ], + "x-codegen-request-body-name" : "body" + } + } + }, + "components" : { + "schemas" : { + "Order" : { + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "petId" : { + "format" : "int64", + "type" : "integer" + }, + "quantity" : { + "format" : "int32", + "type" : "integer" + }, + "shipDate" : { + "format" : "date-time", + "type" : "string" + }, + "status" : { + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" + }, + "complete" : { + "default" : false, + "type" : "boolean" + } + }, + "title" : "Pet Order", + "type" : "object", + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet category", + "type" : "object", + "xml" : { + "name" : "Category" + } + }, + "User" : { + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "username" : { + "type" : "string" + }, + "firstName" : { + "type" : "string" + }, + "lastName" : { + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "password" : { + "type" : "string" + }, + "phone" : { + "type" : "string" + }, + "userStatus" : { + "description" : "User Status", + "format" : "int32", + "type" : "integer" + } + }, + "title" : "a User", + "type" : "object", + "xml" : { + "name" : "User" + } + }, + "Tag" : { + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "name" : { + "type" : "string" + } + }, + "title" : "Pet Tag", + "type" : "object", + "xml" : { + "name" : "Tag" + } + }, + "Pet" : { + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, + "properties" : { + "id" : { + "format" : "int64", + "type" : "integer" + }, + "category" : { + "$ref" : "#/components/schemas/Category" + }, + "name" : { + "example" : "doggie", + "type" : "string" + }, + "photoUrls" : { + "items" : { + "type" : "string" + }, + "type" : "array", + "xml" : { + "name" : "photoUrl", + "wrapped" : true + } + }, + "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, + "type" : "array", + "xml" : { + "name" : "tag", + "wrapped" : true + } + }, + "status" : { + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + } + }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", + "xml" : { + "name" : "Pet" + } + }, + "ApiResponse" : { + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, + "properties" : { + "code" : { + "format" : "int32", + "type" : "integer" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + }, + "title" : "An uploaded response", + "type" : "object" + }, + "updatePetWithForm_request" : { + "properties" : { + "name" : { + "description" : "Updated name of the pet", + "type" : "string" + }, + "status" : { + "description" : "Updated status of the pet", + "type" : "string" + } + }, + "type" : "object" + }, + "uploadFile_request" : { + "properties" : { + "additionalMetadata" : { + "description" : "Additional data to pass to server", + "type" : "string" + }, + "file" : { + "description" : "file to upload", + "format" : "binary", + "type" : "string" + } + }, + "type" : "object" + } + }, + "securitySchemes" : { + "petstore_auth" : { + "flows" : { + "implicit" : { + "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", + "scopes" : { + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" + } + } + }, + "type" : "oauth2" + }, + "api_key" : { + "in" : "header", + "name" : "api_key", + "type" : "apiKey" + } + } + }, + "x-original-swagger-version" : "2.0" +} diff --git a/samples/server/petstore/cpp-oatpp/model/Order.hpp b/samples/server/petstore/cpp-oatpp/model/Order.hpp index e69de29bb2d1..3f69abb6a203 100644 --- a/samples/server/petstore/cpp-oatpp/model/Order.hpp +++ b/samples/server/petstore/cpp-oatpp/model/Order.hpp @@ -0,0 +1,59 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* 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. +*/ +/* + * Order.h + * + * An order for a pets from the pet store + */ + +#ifndef Order_H_ +#define Order_H_ + + +#include "oatpp/core/macro/codegen.hpp" +#include "oatpp/core/Types.hpp" + +namespace org::openapitools::server::model +{ + +/* Begin DTO code-generation */ +#include OATPP_CODEGEN_BEGIN(DTO) + +/** + * Message Data-Transfer-Object + */ +class Order : public oatpp::DTO { + + DTO_INIT(Order, DTO /* Extends */) + + DTO_FIELD(oatpp::Int64, id); + DTO_FIELD(oatpp::Boolean, idIsSet); + DTO_FIELD(oatpp::Int64, petId); + DTO_FIELD(oatpp::Boolean, petIdIsSet); + DTO_FIELD(oatpp::Int32, quantity); + DTO_FIELD(oatpp::Boolean, quantityIsSet); + DTO_FIELD(oatpp::String, shipDate); + DTO_FIELD(oatpp::Boolean, shipDateIsSet); + DTO_FIELD(oatpp::String, status); + DTO_FIELD(oatpp::Boolean, statusIsSet); + DTO_FIELD(oatpp::Boolean, complete); + DTO_FIELD(oatpp::Boolean, completeIsSet); + +}; + +/* End DTO code-generation */ +#include OATPP_CODEGEN_END(DTO) + + +} // namespace org::openapitools::server::model + +#endif /* Order_H_ */ diff --git a/samples/server/petstore/cpp-oatpp/model/Tag.hpp b/samples/server/petstore/cpp-oatpp/model/Tag.hpp index e69de29bb2d1..f7941e8e3911 100644 --- a/samples/server/petstore/cpp-oatpp/model/Tag.hpp +++ b/samples/server/petstore/cpp-oatpp/model/Tag.hpp @@ -0,0 +1,51 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* 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. +*/ +/* + * Tag.h + * + * A tag for a pet + */ + +#ifndef Tag_H_ +#define Tag_H_ + + +#include "oatpp/core/macro/codegen.hpp" +#include "oatpp/core/Types.hpp" + +namespace org::openapitools::server::model +{ + +/* Begin DTO code-generation */ +#include OATPP_CODEGEN_BEGIN(DTO) + +/** + * Message Data-Transfer-Object + */ +class Tag : public oatpp::DTO { + + DTO_INIT(Tag, DTO /* Extends */) + + DTO_FIELD(oatpp::Int64, id); + DTO_FIELD(oatpp::Boolean, idIsSet); + DTO_FIELD(oatpp::String, name); + DTO_FIELD(oatpp::Boolean, nameIsSet); + +}; + +/* End DTO code-generation */ +#include OATPP_CODEGEN_END(DTO) + + +} // namespace org::openapitools::server::model + +#endif /* Tag_H_ */ diff --git a/samples/server/petstore/cpp-pistache-everything/model/Order.cpp b/samples/server/petstore/cpp-pistache-everything/model/Order.cpp index e69de29bb2d1..459d6ee5d69a 100644 --- a/samples/server/petstore/cpp-pistache-everything/model/Order.cpp +++ b/samples/server/petstore/cpp-pistache-everything/model/Order.cpp @@ -0,0 +1,251 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* 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. +*/ + + +#include "Order.h" +#include "Helpers.h" + +#include + +namespace org::openapitools::server::model +{ + +Order::Order() +{ + m_Id = 0L; + m_IdIsSet = false; + m_PetId = 0L; + m_PetIdIsSet = false; + m_Quantity = 0; + m_QuantityIsSet = false; + m_ShipDate = ""; + m_ShipDateIsSet = false; + m_Status = ""; + m_StatusIsSet = false; + m_Complete = false; + m_CompleteIsSet = false; + +} + +void Order::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool Order::validate(std::stringstream& msg) const +{ + return validate(msg, ""); +} + +bool Order::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Order" : pathPrefix; + + + return success; +} + +bool Order::operator==(const Order& rhs) const +{ + return + + + + ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && + + + ((!petIdIsSet() && !rhs.petIdIsSet()) || (petIdIsSet() && rhs.petIdIsSet() && getPetId() == rhs.getPetId())) && + + + ((!quantityIsSet() && !rhs.quantityIsSet()) || (quantityIsSet() && rhs.quantityIsSet() && getQuantity() == rhs.getQuantity())) && + + + ((!shipDateIsSet() && !rhs.shipDateIsSet()) || (shipDateIsSet() && rhs.shipDateIsSet() && getShipDate() == rhs.getShipDate())) && + + + ((!statusIsSet() && !rhs.statusIsSet()) || (statusIsSet() && rhs.statusIsSet() && getStatus() == rhs.getStatus())) && + + + ((!completeIsSet() && !rhs.completeIsSet()) || (completeIsSet() && rhs.completeIsSet() && isComplete() == rhs.isComplete())) + + ; +} + +bool Order::operator!=(const Order& rhs) const +{ + return !(*this == rhs); +} + +void to_json(nlohmann::json& j, const Order& o) +{ + j = nlohmann::json::object(); + if(o.idIsSet()) + j["id"] = o.m_Id; + if(o.petIdIsSet()) + j["petId"] = o.m_PetId; + if(o.quantityIsSet()) + j["quantity"] = o.m_Quantity; + if(o.shipDateIsSet()) + j["shipDate"] = o.m_ShipDate; + if(o.statusIsSet()) + j["status"] = o.m_Status; + if(o.completeIsSet()) + j["complete"] = o.m_Complete; + +} + +void from_json(const nlohmann::json& j, Order& o) +{ + if(j.find("id") != j.end()) + { + j.at("id").get_to(o.m_Id); + o.m_IdIsSet = true; + } + if(j.find("petId") != j.end()) + { + j.at("petId").get_to(o.m_PetId); + o.m_PetIdIsSet = true; + } + if(j.find("quantity") != j.end()) + { + j.at("quantity").get_to(o.m_Quantity); + o.m_QuantityIsSet = true; + } + if(j.find("shipDate") != j.end()) + { + j.at("shipDate").get_to(o.m_ShipDate); + o.m_ShipDateIsSet = true; + } + if(j.find("status") != j.end()) + { + j.at("status").get_to(o.m_Status); + o.m_StatusIsSet = true; + } + if(j.find("complete") != j.end()) + { + j.at("complete").get_to(o.m_Complete); + o.m_CompleteIsSet = true; + } + +} + +int64_t Order::getId() const +{ + return m_Id; +} +void Order::setId(int64_t const value) +{ + m_Id = value; + m_IdIsSet = true; +} +bool Order::idIsSet() const +{ + return m_IdIsSet; +} +void Order::unsetId() +{ + m_IdIsSet = false; +} +int64_t Order::getPetId() const +{ + return m_PetId; +} +void Order::setPetId(int64_t const value) +{ + m_PetId = value; + m_PetIdIsSet = true; +} +bool Order::petIdIsSet() const +{ + return m_PetIdIsSet; +} +void Order::unsetPetId() +{ + m_PetIdIsSet = false; +} +int32_t Order::getQuantity() const +{ + return m_Quantity; +} +void Order::setQuantity(int32_t const value) +{ + m_Quantity = value; + m_QuantityIsSet = true; +} +bool Order::quantityIsSet() const +{ + return m_QuantityIsSet; +} +void Order::unsetQuantity() +{ + m_QuantityIsSet = false; +} +std::string Order::getShipDate() const +{ + return m_ShipDate; +} +void Order::setShipDate(std::string const& value) +{ + m_ShipDate = value; + m_ShipDateIsSet = true; +} +bool Order::shipDateIsSet() const +{ + return m_ShipDateIsSet; +} +void Order::unsetShipDate() +{ + m_ShipDateIsSet = false; +} +std::string Order::getStatus() const +{ + return m_Status; +} +void Order::setStatus(std::string const& value) +{ + m_Status = value; + m_StatusIsSet = true; +} +bool Order::statusIsSet() const +{ + return m_StatusIsSet; +} +void Order::unsetStatus() +{ + m_StatusIsSet = false; +} +bool Order::isComplete() const +{ + return m_Complete; +} +void Order::setComplete(bool const value) +{ + m_Complete = value; + m_CompleteIsSet = true; +} +bool Order::completeIsSet() const +{ + return m_CompleteIsSet; +} +void Order::unsetComplete() +{ + m_CompleteIsSet = false; +} + + +} // namespace org::openapitools::server::model + diff --git a/samples/server/petstore/cpp-pistache-nested-schema-refs/api/StoreApi.cpp b/samples/server/petstore/cpp-pistache-nested-schema-refs/api/StoreApi.cpp index e69de29bb2d1..d23f51da8fd2 100644 --- a/samples/server/petstore/cpp-pistache-nested-schema-refs/api/StoreApi.cpp +++ b/samples/server/petstore/cpp-pistache-nested-schema-refs/api/StoreApi.cpp @@ -0,0 +1,103 @@ +/** +* Test swagger file +* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +* +* 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. +*/ + +#include "StoreApi.h" +#include "Helpers.h" + +namespace org::openapitools::server::api +{ + +using namespace org::openapitools::server::helpers; +using namespace org::openapitools::server::model; + +const std::string StoreApi::base = ""; + +StoreApi::StoreApi(const std::shared_ptr& rtr) + : ApiBase(rtr) +{} + +void StoreApi::init() { + setupRoutes(); +} + +void StoreApi::setupRoutes() { + using namespace Pistache::Rest; + + Routes::Get(*router, base + "/pet", Routes::bind(&StoreApi::get_nested_object_handler, this)); + + // Default handler, called when a route is not found + router->addCustomHandler(Routes::bind(&StoreApi::store_api_default_handler, this)); +} + +void StoreApi::handleParsingException(const std::exception& ex, Pistache::Http::ResponseWriter &response) const noexcept { + std::pair codeAndError = handleParsingException(ex); + response.send(codeAndError.first, codeAndError.second); +} + +std::pair StoreApi::handleParsingException(const std::exception& ex) const noexcept { + try { + throw; + } catch (nlohmann::detail::exception &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } catch (org::openapitools::server::helpers::ValidationException &e) { + return std::make_pair(Pistache::Http::Code::Bad_Request, e.what()); + } catch (std::exception &e) { + return std::make_pair(Pistache::Http::Code::Internal_Server_Error, e.what()); + } +} + +void StoreApi::handleOperationException(const std::exception& ex, Pistache::Http::ResponseWriter &response) const noexcept { + std::pair codeAndError = handleOperationException(ex); + response.send(codeAndError.first, codeAndError.second); +} + +std::pair StoreApi::handleOperationException(const std::exception& ex) const noexcept { + return std::make_pair(Pistache::Http::Code::Internal_Server_Error, ex.what()); +} + +void StoreApi::get_nested_object_handler(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response) { + try { + + + + + + + try { + + + + + + this->get_nested_object(response); + } catch (Pistache::Http::HttpError &e) { + response.send(static_cast(e.code()), e.what()); + return; + } catch (std::exception &e) { + this->handleOperationException(e, response); + return; + } + + } catch (std::exception &e) { + response.send(Pistache::Http::Code::Internal_Server_Error, e.what()); + } + + +} + + +void StoreApi::store_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) { + response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist"); +} + +} // namespace org::openapitools::server::api + diff --git a/samples/server/petstore/cpp-pistache/model/Category.cpp b/samples/server/petstore/cpp-pistache/model/Category.cpp index e69de29bb2d1..489c22157ada 100644 --- a/samples/server/petstore/cpp-pistache/model/Category.cpp +++ b/samples/server/petstore/cpp-pistache/model/Category.cpp @@ -0,0 +1,135 @@ +/** +* OpenAPI Petstore +* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. +* +* 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. +*/ + + +#include "Category.h" +#include "Helpers.h" + +#include + +namespace org::openapitools::server::model +{ + +Category::Category() +{ + m_Id = 0L; + m_IdIsSet = false; + m_Name = ""; + m_NameIsSet = false; + +} + +void Category::validate() const +{ + std::stringstream msg; + if (!validate(msg)) + { + throw org::openapitools::server::helpers::ValidationException(msg.str()); + } +} + +bool Category::validate(std::stringstream& msg) const +{ + return validate(msg, ""); +} + +bool Category::validate(std::stringstream& msg, const std::string& pathPrefix) const +{ + bool success = true; + const std::string _pathPrefix = pathPrefix.empty() ? "Category" : pathPrefix; + + + return success; +} + +bool Category::operator==(const Category& rhs) const +{ + return + + + + ((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) && + + + ((!nameIsSet() && !rhs.nameIsSet()) || (nameIsSet() && rhs.nameIsSet() && getName() == rhs.getName())) + + ; +} + +bool Category::operator!=(const Category& rhs) const +{ + return !(*this == rhs); +} + +void to_json(nlohmann::json& j, const Category& o) +{ + j = nlohmann::json::object(); + if(o.idIsSet()) + j["id"] = o.m_Id; + if(o.nameIsSet()) + j["name"] = o.m_Name; + +} + +void from_json(const nlohmann::json& j, Category& o) +{ + if(j.find("id") != j.end()) + { + j.at("id").get_to(o.m_Id); + o.m_IdIsSet = true; + } + if(j.find("name") != j.end()) + { + j.at("name").get_to(o.m_Name); + o.m_NameIsSet = true; + } + +} + +int64_t Category::getId() const +{ + return m_Id; +} +void Category::setId(int64_t const value) +{ + m_Id = value; + m_IdIsSet = true; +} +bool Category::idIsSet() const +{ + return m_IdIsSet; +} +void Category::unsetId() +{ + m_IdIsSet = false; +} +std::string Category::getName() const +{ + return m_Name; +} +void Category::setName(std::string const& value) +{ + m_Name = value; + m_NameIsSet = true; +} +bool Category::nameIsSet() const +{ + return m_NameIsSet; +} +void Category::unsetName() +{ + m_NameIsSet = false; +} + + +} // namespace org::openapitools::server::model + From 06f5b7cab0d51731b49a4b1b3d60ca37e10c5efa Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Mon, 16 Feb 2026 11:14:03 +0100 Subject: [PATCH 06/13] [FIX] model_generic.mustache add exclude_none=True, on .to_str() --- .../resources/python/model_anyof.mustache | 28 +------------------ .../resources/python/model_generic.mustache | 2 +- .../resources/python/model_oneof.mustache | 25 +---------------- .../openapi_client/models/bird.py | 2 +- .../openapi_client/models/category.py | 2 +- .../openapi_client/models/data_query.py | 2 +- .../openapi_client/models/default_value.py | 2 +- .../models/number_properties_only.py | 2 +- .../openapi_client/models/pet.py | 2 +- .../openapi_client/models/query.py | 2 +- .../openapi_client/models/tag.py | 2 +- ...st_form_object_multipart_request_marker.py | 2 +- ...ue_object_all_of_query_object_parameter.py | 2 +- ...rue_array_string_query_object_parameter.py | 2 +- .../python/openapi_client/models/bird.py | 2 +- .../python/openapi_client/models/category.py | 2 +- .../openapi_client/models/data_query.py | 2 +- .../openapi_client/models/default_value.py | 2 +- .../models/number_properties_only.py | 2 +- .../python/openapi_client/models/pet.py | 2 +- .../python/openapi_client/models/query.py | 2 +- .../python/openapi_client/models/tag.py | 2 +- ...st_form_object_multipart_request_marker.py | 2 +- ...ue_object_all_of_query_object_parameter.py | 2 +- ...rue_array_string_query_object_parameter.py | 2 +- .../models/additional_properties_any_type.py | 2 +- .../models/additional_properties_class.py | 2 +- .../models/additional_properties_object.py | 2 +- ...tional_properties_with_description_only.py | 2 +- .../petstore_api/models/all_of_super_model.py | 2 +- .../models/all_of_with_single_ref.py | 2 +- .../petstore_api/models/animal.py | 2 +- .../petstore_api/models/any_of_color.py | 28 +------------------ .../petstore_api/models/any_of_pig.py | 28 +------------------ .../models/array_of_array_of_model.py | 2 +- .../models/array_of_array_of_number_only.py | 2 +- .../models/array_of_number_only.py | 2 +- .../petstore_api/models/array_test.py | 2 +- .../petstore_api/models/base_discriminator.py | 2 +- .../petstore_api/models/basque_pig.py | 2 +- .../petstore_api/models/bathing.py | 2 +- .../petstore_api/models/capitalization.py | 2 +- .../python-aiohttp/petstore_api/models/cat.py | 2 +- .../petstore_api/models/category.py | 2 +- .../models/circular_all_of_ref.py | 2 +- .../models/circular_reference_model.py | 2 +- .../petstore_api/models/class_model.py | 2 +- .../petstore_api/models/client.py | 2 +- .../petstore_api/models/color.py | 25 +---------------- .../petstore_api/models/creature.py | 2 +- .../petstore_api/models/creature_info.py | 2 +- .../petstore_api/models/danish_pig.py | 2 +- .../petstore_api/models/deprecated_object.py | 2 +- .../models/discriminator_all_of_sub.py | 2 +- .../models/discriminator_all_of_super.py | 2 +- .../python-aiohttp/petstore_api/models/dog.py | 2 +- .../petstore_api/models/dummy_model.py | 2 +- .../petstore_api/models/enum_arrays.py | 2 +- .../models/enum_ref_with_default_value.py | 2 +- .../petstore_api/models/enum_test.py | 2 +- .../petstore_api/models/feeding.py | 2 +- .../petstore_api/models/file.py | 2 +- .../models/file_schema_test_class.py | 2 +- .../petstore_api/models/first_ref.py | 2 +- .../python-aiohttp/petstore_api/models/foo.py | 2 +- .../models/foo_get_default_response.py | 2 +- .../petstore_api/models/format_test.py | 2 +- .../petstore_api/models/has_only_read_only.py | 2 +- .../models/health_check_result.py | 2 +- .../petstore_api/models/hunting_dog.py | 2 +- .../petstore_api/models/info.py | 2 +- .../models/inner_dict_with_property.py | 2 +- .../petstore_api/models/input_all_of.py | 2 +- .../petstore_api/models/int_or_string.py | 25 +---------------- .../petstore_api/models/list_class.py | 2 +- .../models/map_of_array_of_model.py | 2 +- .../petstore_api/models/map_test.py | 2 +- ...perties_and_additional_properties_class.py | 2 +- .../petstore_api/models/model200_response.py | 2 +- .../petstore_api/models/model_api_response.py | 2 +- .../petstore_api/models/model_field.py | 2 +- .../petstore_api/models/model_return.py | 2 +- .../petstore_api/models/multi_arrays.py | 2 +- .../petstore_api/models/name.py | 2 +- .../petstore_api/models/nullable_class.py | 2 +- .../petstore_api/models/nullable_property.py | 2 +- .../petstore_api/models/number_only.py | 2 +- .../object_to_test_additional_properties.py | 2 +- .../models/object_with_deprecated_fields.py | 2 +- .../petstore_api/models/order.py | 2 +- .../petstore_api/models/outer_composite.py | 2 +- .../models/outer_object_with_enum_property.py | 2 +- .../petstore_api/models/parent.py | 2 +- .../models/parent_with_optional_dict.py | 2 +- .../python-aiohttp/petstore_api/models/pet.py | 2 +- .../python-aiohttp/petstore_api/models/pig.py | 25 +---------------- .../petstore_api/models/pony_sizes.py | 2 +- .../petstore_api/models/poop_cleaning.py | 2 +- .../petstore_api/models/primitive_string.py | 2 +- .../petstore_api/models/property_map.py | 2 +- .../models/property_name_collision.py | 2 +- .../petstore_api/models/read_only_first.py | 2 +- .../models/second_circular_all_of_ref.py | 2 +- .../petstore_api/models/second_ref.py | 2 +- .../models/self_reference_model.py | 2 +- .../petstore_api/models/special_model_name.py | 2 +- .../petstore_api/models/special_name.py | 2 +- .../python-aiohttp/petstore_api/models/tag.py | 2 +- .../petstore_api/models/task.py | 2 +- .../petstore_api/models/task_activity.py | 25 +---------------- ..._error_responses_with_model400_response.py | 2 +- ..._error_responses_with_model404_response.py | 2 +- ..._freeform_additional_properties_request.py | 2 +- .../models/test_model_with_enum_default.py | 2 +- ...t_for_multipart_requests_request_marker.py | 2 +- .../petstore_api/models/tiger.py | 2 +- ...t_with_additional_model_list_properties.py | 2 +- ..._with_additional_string_list_properties.py | 2 +- ...th_additional_properties_request_object.py | 2 +- .../petstore_api/models/user.py | 2 +- .../petstore_api/models/with_nested_one_of.py | 2 +- .../models/additional_properties_any_type.py | 2 +- .../models/additional_properties_class.py | 2 +- .../models/additional_properties_object.py | 2 +- ...tional_properties_with_description_only.py | 2 +- .../petstore_api/models/all_of_super_model.py | 2 +- .../models/all_of_with_single_ref.py | 2 +- .../petstore_api/models/animal.py | 2 +- .../petstore_api/models/any_of_color.py | 28 +------------------ .../petstore_api/models/any_of_pig.py | 28 +------------------ .../models/array_of_array_of_model.py | 2 +- .../models/array_of_array_of_number_only.py | 2 +- .../models/array_of_number_only.py | 2 +- .../petstore_api/models/array_test.py | 2 +- .../petstore_api/models/base_discriminator.py | 2 +- .../petstore_api/models/basque_pig.py | 2 +- .../petstore_api/models/bathing.py | 2 +- .../petstore_api/models/capitalization.py | 2 +- .../python-httpx/petstore_api/models/cat.py | 2 +- .../petstore_api/models/category.py | 2 +- .../models/circular_all_of_ref.py | 2 +- .../models/circular_reference_model.py | 2 +- .../petstore_api/models/class_model.py | 2 +- .../petstore_api/models/client.py | 2 +- .../python-httpx/petstore_api/models/color.py | 25 +---------------- .../petstore_api/models/creature.py | 2 +- .../petstore_api/models/creature_info.py | 2 +- .../petstore_api/models/danish_pig.py | 2 +- .../petstore_api/models/deprecated_object.py | 2 +- .../models/discriminator_all_of_sub.py | 2 +- .../models/discriminator_all_of_super.py | 2 +- .../python-httpx/petstore_api/models/dog.py | 2 +- .../petstore_api/models/dummy_model.py | 2 +- .../petstore_api/models/enum_arrays.py | 2 +- .../models/enum_ref_with_default_value.py | 2 +- .../petstore_api/models/enum_test.py | 2 +- .../petstore_api/models/feeding.py | 2 +- .../python-httpx/petstore_api/models/file.py | 2 +- .../models/file_schema_test_class.py | 2 +- .../petstore_api/models/first_ref.py | 2 +- .../python-httpx/petstore_api/models/foo.py | 2 +- .../models/foo_get_default_response.py | 2 +- .../petstore_api/models/format_test.py | 2 +- .../petstore_api/models/has_only_read_only.py | 2 +- .../models/health_check_result.py | 2 +- .../petstore_api/models/hunting_dog.py | 2 +- .../python-httpx/petstore_api/models/info.py | 2 +- .../models/inner_dict_with_property.py | 2 +- .../petstore_api/models/input_all_of.py | 2 +- .../petstore_api/models/int_or_string.py | 25 +---------------- .../petstore_api/models/list_class.py | 2 +- .../models/map_of_array_of_model.py | 2 +- .../petstore_api/models/map_test.py | 2 +- ...perties_and_additional_properties_class.py | 2 +- .../petstore_api/models/model200_response.py | 2 +- .../petstore_api/models/model_api_response.py | 2 +- .../petstore_api/models/model_field.py | 2 +- .../petstore_api/models/model_return.py | 2 +- .../petstore_api/models/multi_arrays.py | 2 +- .../python-httpx/petstore_api/models/name.py | 2 +- .../petstore_api/models/nullable_class.py | 2 +- .../petstore_api/models/nullable_property.py | 2 +- .../petstore_api/models/number_only.py | 2 +- .../object_to_test_additional_properties.py | 2 +- .../models/object_with_deprecated_fields.py | 2 +- .../python-httpx/petstore_api/models/order.py | 2 +- .../petstore_api/models/outer_composite.py | 2 +- .../models/outer_object_with_enum_property.py | 2 +- .../petstore_api/models/parent.py | 2 +- .../models/parent_with_optional_dict.py | 2 +- .../python-httpx/petstore_api/models/pet.py | 2 +- .../python-httpx/petstore_api/models/pig.py | 25 +---------------- .../petstore_api/models/pony_sizes.py | 2 +- .../petstore_api/models/poop_cleaning.py | 2 +- .../petstore_api/models/primitive_string.py | 2 +- .../petstore_api/models/property_map.py | 2 +- .../models/property_name_collision.py | 2 +- .../petstore_api/models/read_only_first.py | 2 +- .../models/second_circular_all_of_ref.py | 2 +- .../petstore_api/models/second_ref.py | 2 +- .../models/self_reference_model.py | 2 +- .../petstore_api/models/special_model_name.py | 2 +- .../petstore_api/models/special_name.py | 2 +- .../python-httpx/petstore_api/models/tag.py | 2 +- .../python-httpx/petstore_api/models/task.py | 2 +- .../petstore_api/models/task_activity.py | 25 +---------------- ..._error_responses_with_model400_response.py | 2 +- ..._error_responses_with_model404_response.py | 2 +- ..._freeform_additional_properties_request.py | 2 +- .../models/test_model_with_enum_default.py | 2 +- ...t_for_multipart_requests_request_marker.py | 2 +- .../python-httpx/petstore_api/models/tiger.py | 2 +- ...t_with_additional_model_list_properties.py | 2 +- ..._with_additional_string_list_properties.py | 2 +- ...th_additional_properties_request_object.py | 2 +- .../python-httpx/petstore_api/models/user.py | 2 +- .../petstore_api/models/with_nested_one_of.py | 2 +- .../models/additional_properties_any_type.py | 2 +- .../models/additional_properties_class.py | 2 +- .../models/additional_properties_object.py | 2 +- ...tional_properties_with_description_only.py | 2 +- .../petstore_api/models/all_of_super_model.py | 2 +- .../models/all_of_with_single_ref.py | 2 +- .../petstore_api/models/animal.py | 2 +- .../petstore_api/models/any_of_color.py | 28 +------------------ .../petstore_api/models/any_of_pig.py | 28 +------------------ .../models/array_of_array_of_model.py | 2 +- .../models/array_of_array_of_number_only.py | 2 +- .../models/array_of_number_only.py | 2 +- .../petstore_api/models/array_test.py | 2 +- .../petstore_api/models/base_discriminator.py | 2 +- .../petstore_api/models/basque_pig.py | 2 +- .../petstore_api/models/bathing.py | 2 +- .../petstore_api/models/capitalization.py | 2 +- .../petstore_api/models/cat.py | 2 +- .../petstore_api/models/category.py | 2 +- .../models/circular_all_of_ref.py | 2 +- .../models/circular_reference_model.py | 2 +- .../petstore_api/models/class_model.py | 2 +- .../petstore_api/models/client.py | 2 +- .../petstore_api/models/color.py | 25 +---------------- .../petstore_api/models/creature.py | 2 +- .../petstore_api/models/creature_info.py | 2 +- .../petstore_api/models/danish_pig.py | 2 +- .../petstore_api/models/deprecated_object.py | 2 +- .../models/discriminator_all_of_sub.py | 2 +- .../models/discriminator_all_of_super.py | 2 +- .../petstore_api/models/dog.py | 2 +- .../petstore_api/models/dummy_model.py | 2 +- .../petstore_api/models/enum_arrays.py | 2 +- .../models/enum_ref_with_default_value.py | 2 +- .../petstore_api/models/enum_test.py | 2 +- .../petstore_api/models/feeding.py | 2 +- .../petstore_api/models/file.py | 2 +- .../models/file_schema_test_class.py | 2 +- .../petstore_api/models/first_ref.py | 2 +- .../petstore_api/models/foo.py | 2 +- .../models/foo_get_default_response.py | 2 +- .../petstore_api/models/format_test.py | 2 +- .../petstore_api/models/has_only_read_only.py | 2 +- .../models/health_check_result.py | 2 +- .../petstore_api/models/hunting_dog.py | 2 +- .../petstore_api/models/info.py | 2 +- .../models/inner_dict_with_property.py | 2 +- .../petstore_api/models/input_all_of.py | 2 +- .../petstore_api/models/int_or_string.py | 25 +---------------- .../petstore_api/models/list_class.py | 2 +- .../models/map_of_array_of_model.py | 2 +- .../petstore_api/models/map_test.py | 2 +- ...perties_and_additional_properties_class.py | 2 +- .../petstore_api/models/model200_response.py | 2 +- .../petstore_api/models/model_api_response.py | 2 +- .../petstore_api/models/model_field.py | 2 +- .../petstore_api/models/model_return.py | 2 +- .../petstore_api/models/multi_arrays.py | 2 +- .../petstore_api/models/name.py | 2 +- .../petstore_api/models/nullable_class.py | 2 +- .../petstore_api/models/nullable_property.py | 2 +- .../petstore_api/models/number_only.py | 2 +- .../object_to_test_additional_properties.py | 2 +- .../models/object_with_deprecated_fields.py | 2 +- .../petstore_api/models/one_of_enum_string.py | 25 +---------------- .../petstore_api/models/order.py | 2 +- .../petstore_api/models/outer_composite.py | 2 +- .../models/outer_object_with_enum_property.py | 2 +- .../petstore_api/models/parent.py | 2 +- .../models/parent_with_optional_dict.py | 2 +- .../petstore_api/models/pet.py | 2 +- .../petstore_api/models/pig.py | 25 +---------------- .../petstore_api/models/pony_sizes.py | 2 +- .../petstore_api/models/poop_cleaning.py | 2 +- .../petstore_api/models/primitive_string.py | 2 +- .../petstore_api/models/property_map.py | 2 +- .../models/property_name_collision.py | 2 +- .../petstore_api/models/read_only_first.py | 2 +- .../models/second_circular_all_of_ref.py | 2 +- .../petstore_api/models/second_ref.py | 2 +- .../models/self_reference_model.py | 2 +- .../petstore_api/models/special_model_name.py | 2 +- .../petstore_api/models/special_name.py | 2 +- .../petstore_api/models/tag.py | 2 +- .../petstore_api/models/task.py | 2 +- .../petstore_api/models/task_activity.py | 25 +---------------- ..._error_responses_with_model400_response.py | 2 +- ..._error_responses_with_model404_response.py | 2 +- ..._freeform_additional_properties_request.py | 2 +- .../models/test_model_with_enum_default.py | 2 +- ...t_for_multipart_requests_request_marker.py | 2 +- .../petstore_api/models/tiger.py | 2 +- ...t_with_additional_model_list_properties.py | 2 +- ..._with_additional_string_list_properties.py | 2 +- ...th_additional_properties_request_object.py | 2 +- .../petstore_api/models/user.py | 2 +- .../petstore_api/models/with_nested_one_of.py | 2 +- .../models/additional_properties_any_type.py | 2 +- .../models/additional_properties_class.py | 2 +- .../models/additional_properties_object.py | 2 +- ...tional_properties_with_description_only.py | 2 +- .../petstore_api/models/all_of_super_model.py | 2 +- .../models/all_of_with_single_ref.py | 2 +- .../python/petstore_api/models/animal.py | 2 +- .../petstore_api/models/any_of_color.py | 28 +------------------ .../python/petstore_api/models/any_of_pig.py | 28 +------------------ .../models/array_of_array_of_model.py | 2 +- .../models/array_of_array_of_number_only.py | 2 +- .../models/array_of_number_only.py | 2 +- .../python/petstore_api/models/array_test.py | 2 +- .../petstore_api/models/base_discriminator.py | 2 +- .../python/petstore_api/models/basque_pig.py | 2 +- .../python/petstore_api/models/bathing.py | 2 +- .../petstore_api/models/capitalization.py | 2 +- .../python/petstore_api/models/cat.py | 2 +- .../python/petstore_api/models/category.py | 2 +- .../models/circular_all_of_ref.py | 2 +- .../models/circular_reference_model.py | 2 +- .../python/petstore_api/models/class_model.py | 2 +- .../python/petstore_api/models/client.py | 2 +- .../python/petstore_api/models/color.py | 25 +---------------- .../python/petstore_api/models/creature.py | 2 +- .../petstore_api/models/creature_info.py | 2 +- .../python/petstore_api/models/danish_pig.py | 2 +- .../petstore_api/models/deprecated_object.py | 2 +- .../models/discriminator_all_of_sub.py | 2 +- .../models/discriminator_all_of_super.py | 2 +- .../python/petstore_api/models/dog.py | 2 +- .../python/petstore_api/models/dummy_model.py | 2 +- .../python/petstore_api/models/enum_arrays.py | 2 +- .../models/enum_ref_with_default_value.py | 2 +- .../python/petstore_api/models/enum_test.py | 2 +- .../python/petstore_api/models/feeding.py | 2 +- .../python/petstore_api/models/file.py | 2 +- .../models/file_schema_test_class.py | 2 +- .../python/petstore_api/models/first_ref.py | 2 +- .../python/petstore_api/models/foo.py | 2 +- .../models/foo_get_default_response.py | 2 +- .../python/petstore_api/models/format_test.py | 2 +- .../petstore_api/models/has_only_read_only.py | 2 +- .../models/health_check_result.py | 2 +- .../python/petstore_api/models/hunting_dog.py | 2 +- .../python/petstore_api/models/info.py | 2 +- .../models/inner_dict_with_property.py | 2 +- .../petstore_api/models/input_all_of.py | 2 +- .../petstore_api/models/int_or_string.py | 25 +---------------- .../python/petstore_api/models/list_class.py | 2 +- .../models/map_of_array_of_model.py | 2 +- .../python/petstore_api/models/map_test.py | 2 +- ...perties_and_additional_properties_class.py | 2 +- .../petstore_api/models/model200_response.py | 2 +- .../petstore_api/models/model_api_response.py | 2 +- .../python/petstore_api/models/model_field.py | 2 +- .../petstore_api/models/model_return.py | 2 +- .../petstore_api/models/multi_arrays.py | 2 +- .../python/petstore_api/models/name.py | 2 +- .../petstore_api/models/nullable_class.py | 2 +- .../petstore_api/models/nullable_property.py | 2 +- .../python/petstore_api/models/number_only.py | 2 +- .../object_to_test_additional_properties.py | 2 +- .../models/object_with_deprecated_fields.py | 2 +- .../petstore_api/models/one_of_enum_string.py | 25 +---------------- .../python/petstore_api/models/order.py | 2 +- .../petstore_api/models/outer_composite.py | 2 +- .../models/outer_object_with_enum_property.py | 2 +- .../python/petstore_api/models/parent.py | 2 +- .../models/parent_with_optional_dict.py | 2 +- .../python/petstore_api/models/pet.py | 2 +- .../python/petstore_api/models/pig.py | 25 +---------------- .../python/petstore_api/models/pony_sizes.py | 2 +- .../petstore_api/models/poop_cleaning.py | 2 +- .../petstore_api/models/primitive_string.py | 2 +- .../petstore_api/models/property_map.py | 2 +- .../models/property_name_collision.py | 2 +- .../petstore_api/models/read_only_first.py | 2 +- .../models/second_circular_all_of_ref.py | 2 +- .../python/petstore_api/models/second_ref.py | 2 +- .../models/self_reference_model.py | 2 +- .../petstore_api/models/special_model_name.py | 2 +- .../petstore_api/models/special_name.py | 2 +- .../python/petstore_api/models/tag.py | 2 +- .../python/petstore_api/models/task.py | 2 +- .../petstore_api/models/task_activity.py | 25 +---------------- ..._error_responses_with_model400_response.py | 2 +- ..._error_responses_with_model404_response.py | 2 +- ..._freeform_additional_properties_request.py | 2 +- .../models/test_model_with_enum_default.py | 2 +- ...t_for_multipart_requests_request_marker.py | 2 +- .../python/petstore_api/models/tiger.py | 2 +- ...t_with_additional_model_list_properties.py | 2 +- ..._with_additional_string_list_properties.py | 2 +- ...th_additional_properties_request_object.py | 2 +- .../python/petstore_api/models/user.py | 2 +- .../petstore_api/models/with_nested_one_of.py | 2 +- 411 files changed, 411 insertions(+), 1082 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index 8d1899716b69..e0f5246a7256 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -1,6 +1,4 @@ from __future__ import annotations -import pprint -import re # noqa: F401 {{#vendorExtensions.x-py-other-imports}} {{{.}}} {{/vendorExtensions.x-py-other-imports}} @@ -18,9 +16,8 @@ class {{classname}}(RootModel[Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyO """ {{{description}}}{{^description}}{{{classname}}}{{/description}} """ - root: Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}{{#isNullable}}, None{{/isNullable}}] = Field( - {{#isNullable}}None{{/isNullable}}{{^isNullable}}...{{/isNullable}}{{#discriminator}}, discriminator="{{discriminatorName}}"{{/discriminator}} + {{#isNullable}}None{{/isNullable}}{{^isNullable}}...{{/isNullable}}{{#discriminator}}, discriminator="{{discriminatorName}}"{{/discriminator}} ) def __getattr__(self, name): @@ -38,29 +35,6 @@ class {{classname}}(RootModel[Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyO raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - - {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} {{{.}}} diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index a423133d34a6..18f3a8894715 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -176,7 +176,7 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) {{#vendorExtensions.x-py-postponed-model-imports.size}} diff --git a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache index 03f0766ea3e0..a20411ede0d9 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -1,6 +1,4 @@ from __future__ import annotations -import json -import pprint {{#vendorExtensions.x-py-other-imports}} {{{.}}} {{/vendorExtensions.x-py-other-imports}} @@ -13,6 +11,7 @@ from typing_extensions import Literal, Self {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ONE_OF_SCHEMAS = [{{#oneOf}}"{{.}}"{{^-last}}, {{/-last}}{{/oneOf}}] + class {{classname}}(RootModel[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}]]): """ {{{description}}}{{^description}}{{{classname}}}{{/description}} @@ -36,28 +35,6 @@ class {{classname}}(RootModel[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/on raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} {{{.}}} diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py index 3d968f7ccb2a..1a2f2d798c10 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py index 6eff61d49cd5..9370c2c6e41e 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py index b1c63f49eb43..63f2fd374a96 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py index 10e69104c4e4..b14289b63af4 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py index 6f0dc9bac787..7e47285007bd 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py index f266995ab4be..0ab779eea809 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py @@ -78,7 +78,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py index cd07519afcee..5066d9aeeb90 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py @@ -73,7 +73,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py index 629143cb5037..566558fafa64 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py index a0e8fa663e86..0c24a9c487f1 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index f1d93067251e..653d4b7154d7 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index e0fe6d0f8e3d..82ab35a69c58 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/bird.py b/samples/client/echo_api/python/openapi_client/models/bird.py index 3d968f7ccb2a..1a2f2d798c10 100644 --- a/samples/client/echo_api/python/openapi_client/models/bird.py +++ b/samples/client/echo_api/python/openapi_client/models/bird.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/category.py b/samples/client/echo_api/python/openapi_client/models/category.py index 6eff61d49cd5..9370c2c6e41e 100644 --- a/samples/client/echo_api/python/openapi_client/models/category.py +++ b/samples/client/echo_api/python/openapi_client/models/category.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/data_query.py b/samples/client/echo_api/python/openapi_client/models/data_query.py index b1c63f49eb43..63f2fd374a96 100644 --- a/samples/client/echo_api/python/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python/openapi_client/models/data_query.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/default_value.py b/samples/client/echo_api/python/openapi_client/models/default_value.py index 10e69104c4e4..b14289b63af4 100644 --- a/samples/client/echo_api/python/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python/openapi_client/models/default_value.py @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py index 6f0dc9bac787..7e47285007bd 100644 --- a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/pet.py b/samples/client/echo_api/python/openapi_client/models/pet.py index f266995ab4be..0ab779eea809 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -78,7 +78,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/query.py b/samples/client/echo_api/python/openapi_client/models/query.py index cd07519afcee..5066d9aeeb90 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -73,7 +73,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/tag.py b/samples/client/echo_api/python/openapi_client/models/tag.py index 629143cb5037..566558fafa64 100644 --- a/samples/client/echo_api/python/openapi_client/models/tag.py +++ b/samples/client/echo_api/python/openapi_client/models/tag.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py index a0e8fa663e86..0c24a9c487f1 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index f1d93067251e..653d4b7154d7 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index e0fe6d0f8e3d..82ab35a69c58 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py index 9c810c176590..3243abe84898 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py index ddbba0f2757e..ce0a36181d9c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py index 75df3dc97cf4..b6d64b98588d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py index a3dea0ab8ee6..4d20d077a968 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py index 69652540470a..c47abd4a04bd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py index e76a1fde6648..2356cd8dd8e2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py index 2895047545a5..e9c7c3d1fa1d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py index b86b03be3591..709f0340d8d1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py @@ -13,8 +13,6 @@ from __future__ import annotations -import pprint -import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated @@ -29,9 +27,8 @@ class AnyOfColor(RootModel[Union[List[int], str]]): """ Any of RGB array, RGBA array, or hex string. """ - root: Union[List[int], str] = Field( - ... + ... ) def __getattr__(self, name): @@ -49,27 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - - diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py index a632d3c382d6..43dac2f68c23 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -import pprint -import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Optional from petstore_api.models.basque_pig import BasquePig @@ -30,9 +28,8 @@ class AnyOfPig(RootModel[Union[BasquePig, DanishPig]]): """ AnyOfPig """ - root: Union[BasquePig, DanishPig] = Field( - ... + ... ) def __getattr__(self, name): @@ -50,27 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - - diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py index dfc9ac6c4ca5..2b46cb9082e0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py index 3ad948c9440d..dd845d845682 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py index 1d4adc5a950a..331547535ef8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py index 5adbf20df093..89662a882d07 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py index 9503c06d45bc..83ce91145b77 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py index 34c4a06b6cbd..ee8182d48596 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py index 732c1aa3042a..3bb60f92db62 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py index 28449afd3e5a..342ad31326eb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py index 4a93e75fad72..2dd0d3274708 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py index aa4daee49387..b62765b8abe9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py index 208e5958632d..0d01949fd3a7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py index f3a5c5c72ceb..420a7700bc53 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py index 39b738f37734..8deb7604d73d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py index f0cce9f3cb96..c57eb6918ec6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py index 5197fe58ecc6..608ec222a231 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated @@ -24,6 +22,7 @@ COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] + class Color(RootModel[Union[List[int], str]]): """ RGB array, RGBA array, or hex string. @@ -47,26 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py index 9f3f914c2b72..ae313c628569 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py index 9b70835e860e..bcb6ea307276 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py index b9521312c8e8..592ccac211ba 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py index 3c7fbe91d2f2..caf2b0d78d43 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py index 9f5f1144a513..fd9be92727e7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py index f2e5c978592b..714b8a42a01c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py index ee2df1d87aac..538d3616e5ad 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py index f2ddcef5972a..4be00a640f44 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index 5a46c33280ca..2fbb097353c9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -85,7 +85,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py index b51873522c71..4a1cea1436c7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index cc8235f31d2f..56d8b7287877 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -165,7 +165,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py index ed0623f5e1ca..8638cd00fe8a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py index 39a9df75cceb..7b2816382d25 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py index 8a35d95893ab..b82b9f90af6c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py index 13bee22b64e4..f67d802c74f9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py index a1b2ca180494..8467a776ad15 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py index 3fe6d71bf00e..f673ffc6f416 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py index 368933863a9a..a3ba4438023c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py @@ -117,7 +117,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py index 07a8241f5eb4..cddd46e070a2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py index eb842ad8defc..df31f576e8d0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py index 9460c3da660e..968d03abf360 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py index 9a4cf4070256..b5da7906f325 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py index 3165bf3a065d..18db6118e37c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py index cc09b8ea0c29..6387a99bcb83 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py index c66bf1ab9772..b57c4c9d0f36 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated @@ -24,6 +22,7 @@ INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] + class IntOrString(RootModel[Union[int, str]]): """ IntOrString @@ -47,26 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py index 0a5f1ac36d43..ce4d06f08640 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index bd926af80b11..56f10646cda8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index 591b729eb6a1..da55a55ae9a9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -74,7 +74,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py index d4f415fe0afa..a825e0674f2e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py index f4186542b9e7..8ad3b791e847 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py index 4556075a0995..afb355204443 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py index eed3b9237d74..5d694957fb29 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py index a6760c8a3650..985aca80fd1b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py index b50d7f9ad4b3..e6ada1f449a7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py index 67265006c173..cfc732d9cae1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py index 19824ad3bfcc..e5a76bc2dbcf 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py @@ -71,7 +71,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py index 57dd94a70c10..24b30652d657 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py @@ -69,7 +69,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py index 5745c6ae695f..e1514ebc34a6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py index 0823a0a2474b..8c8853839c41 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py index e9ef0f373e91..9c278d447867 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index 0b8441532ba5..a61af35b7e23 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -76,7 +76,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py index fe85ee49ca06..ebba5f003946 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py index 4daabab35807..9b77e7363bb3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py index 347ed325ae05..62714c8d3914 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py index 6cab92407738..8893c7410ce2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index dbef9d16f443..498647673e14 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -78,7 +78,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py index 6646e6d477cd..309874d6481b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig @@ -25,6 +23,7 @@ PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] + class Pig(RootModel[Union[BasquePig, DanishPig]]): """ Pig @@ -48,26 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py index bed85efa276c..4100e19edfd0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py index 8f972d517236..aa76a7136dd7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py index a811f9d7c3f2..84c5aea4607f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py index 135c6a6860b4..1aa526d746cc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py index 1dca692c008d..56368f36779d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py index 174d6b75a6ad..1e2b91f0a55d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py index 7017d2434765..b774593ebc5e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py index fb545192214a..780b551e5f8e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py index deabec983d4f..cf4e009f56d8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py index 90861e4568ae..4b5d66090bd5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index 370785af0987..af08b2106da7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -73,7 +73,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py index 575db976ade6..6957ece5b860 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py index 18d6282e2c05..17e86a00e7d5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py index 39a1c0bbc375..15b92f1829bf 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.bathing import Bathing @@ -26,6 +24,7 @@ TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] + class TaskActivity(RootModel[Union[Bathing, Feeding, PoopCleaning]]): """ TaskActivity @@ -49,26 +48,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py index 622dc55b5ecc..3bf11509bad1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py index ea5be0d8c54e..03d05b7be8af 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py index b8ae3f003698..d65b57c11542 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py index ac92886923bf..23503db6242f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py @@ -76,7 +76,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py index 26432529a3c8..af27ab2be1c6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py index 3b2ffcf9d159..08c0614678d3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 07103b7095d6..a3663250ae02 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index cf92d499f17b..15a34aee42d4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py index 6d5c954aa65d..200bdb807c9c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py index 5567c69c2c64..02fb2683e524 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py @@ -64,7 +64,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py index 7f800931c63b..4d0323da7999 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py index 9c810c176590..3243abe84898 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py index ddbba0f2757e..ce0a36181d9c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py index 75df3dc97cf4..b6d64b98588d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py index a3dea0ab8ee6..4d20d077a968 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py index 69652540470a..c47abd4a04bd 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py index e76a1fde6648..2356cd8dd8e2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py index 2895047545a5..e9c7c3d1fa1d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py index b86b03be3591..709f0340d8d1 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py @@ -13,8 +13,6 @@ from __future__ import annotations -import pprint -import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated @@ -29,9 +27,8 @@ class AnyOfColor(RootModel[Union[List[int], str]]): """ Any of RGB array, RGBA array, or hex string. """ - root: Union[List[int], str] = Field( - ... + ... ) def __getattr__(self, name): @@ -49,27 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - - diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py index a632d3c382d6..43dac2f68c23 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -import pprint -import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Optional from petstore_api.models.basque_pig import BasquePig @@ -30,9 +28,8 @@ class AnyOfPig(RootModel[Union[BasquePig, DanishPig]]): """ AnyOfPig """ - root: Union[BasquePig, DanishPig] = Field( - ... + ... ) def __getattr__(self, name): @@ -50,27 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - - diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py index dfc9ac6c4ca5..2b46cb9082e0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py index 3ad948c9440d..dd845d845682 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py index 1d4adc5a950a..331547535ef8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py index 5adbf20df093..89662a882d07 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py index 9503c06d45bc..83ce91145b77 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py index 34c4a06b6cbd..ee8182d48596 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py index 732c1aa3042a..3bb60f92db62 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py index 28449afd3e5a..342ad31326eb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py index 4a93e75fad72..2dd0d3274708 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py index aa4daee49387..b62765b8abe9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py index 208e5958632d..0d01949fd3a7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py index f3a5c5c72ceb..420a7700bc53 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py index 39b738f37734..8deb7604d73d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py index f0cce9f3cb96..c57eb6918ec6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py index 5197fe58ecc6..608ec222a231 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated @@ -24,6 +22,7 @@ COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] + class Color(RootModel[Union[List[int], str]]): """ RGB array, RGBA array, or hex string. @@ -47,26 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py index 9f3f914c2b72..ae313c628569 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py index 9b70835e860e..bcb6ea307276 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py index b9521312c8e8..592ccac211ba 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py index 3c7fbe91d2f2..caf2b0d78d43 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py index 9f5f1144a513..fd9be92727e7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py index f2e5c978592b..714b8a42a01c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py index ee2df1d87aac..538d3616e5ad 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py index f2ddcef5972a..4be00a640f44 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py index 5a46c33280ca..2fbb097353c9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py @@ -85,7 +85,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py index b51873522c71..4a1cea1436c7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py index cc8235f31d2f..56d8b7287877 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py @@ -165,7 +165,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py index ed0623f5e1ca..8638cd00fe8a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py index 39a9df75cceb..7b2816382d25 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py index 8a35d95893ab..b82b9f90af6c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py index 13bee22b64e4..f67d802c74f9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py index a1b2ca180494..8467a776ad15 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py index 3fe6d71bf00e..f673ffc6f416 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py index 368933863a9a..a3ba4438023c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py @@ -117,7 +117,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py index 07a8241f5eb4..cddd46e070a2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py index eb842ad8defc..df31f576e8d0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py index 9460c3da660e..968d03abf360 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py index 9a4cf4070256..b5da7906f325 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py index 3165bf3a065d..18db6118e37c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py index cc09b8ea0c29..6387a99bcb83 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py index c66bf1ab9772..b57c4c9d0f36 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated @@ -24,6 +22,7 @@ INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] + class IntOrString(RootModel[Union[int, str]]): """ IntOrString @@ -47,26 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py index 0a5f1ac36d43..ce4d06f08640 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py index bd926af80b11..56f10646cda8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py index 591b729eb6a1..da55a55ae9a9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py @@ -74,7 +74,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py index d4f415fe0afa..a825e0674f2e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py index f4186542b9e7..8ad3b791e847 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py index 4556075a0995..afb355204443 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py index eed3b9237d74..5d694957fb29 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py index a6760c8a3650..985aca80fd1b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py index b50d7f9ad4b3..e6ada1f449a7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py index 67265006c173..cfc732d9cae1 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py index 19824ad3bfcc..e5a76bc2dbcf 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py @@ -71,7 +71,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py index 57dd94a70c10..24b30652d657 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py @@ -69,7 +69,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py index 5745c6ae695f..e1514ebc34a6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py index 0823a0a2474b..8c8853839c41 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py index e9ef0f373e91..9c278d447867 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py index 0b8441532ba5..a61af35b7e23 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py @@ -76,7 +76,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py index fe85ee49ca06..ebba5f003946 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py index 4daabab35807..9b77e7363bb3 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py index 347ed325ae05..62714c8d3914 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py index 6cab92407738..8893c7410ce2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py index dbef9d16f443..498647673e14 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py @@ -78,7 +78,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py index 6646e6d477cd..309874d6481b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig @@ -25,6 +23,7 @@ PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] + class Pig(RootModel[Union[BasquePig, DanishPig]]): """ Pig @@ -48,26 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py index bed85efa276c..4100e19edfd0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py index 8f972d517236..aa76a7136dd7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py index a811f9d7c3f2..84c5aea4607f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py index 135c6a6860b4..1aa526d746cc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py index 1dca692c008d..56368f36779d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py index 174d6b75a6ad..1e2b91f0a55d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py index 7017d2434765..b774593ebc5e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py index fb545192214a..780b551e5f8e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py index deabec983d4f..cf4e009f56d8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py index 90861e4568ae..4b5d66090bd5 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py index 370785af0987..af08b2106da7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py @@ -73,7 +73,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py index 575db976ade6..6957ece5b860 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py index 18d6282e2c05..17e86a00e7d5 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py index 39a1c0bbc375..15b92f1829bf 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.bathing import Bathing @@ -26,6 +24,7 @@ TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] + class TaskActivity(RootModel[Union[Bathing, Feeding, PoopCleaning]]): """ TaskActivity @@ -49,26 +48,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py index 622dc55b5ecc..3bf11509bad1 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py index ea5be0d8c54e..03d05b7be8af 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py index b8ae3f003698..d65b57c11542 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py index ac92886923bf..23503db6242f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py @@ -76,7 +76,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py index 26432529a3c8..af27ab2be1c6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py index 3b2ffcf9d159..08c0614678d3 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 07103b7095d6..a3663250ae02 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index cf92d499f17b..15a34aee42d4 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py index 6d5c954aa65d..200bdb807c9c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -57,7 +57,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py index 5567c69c2c64..02fb2683e524 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py @@ -64,7 +64,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py index 7f800931c63b..4d0323da7999 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py index 9c810c176590..3243abe84898 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py index a17e1f1dcb36..87cc8a3f2a2a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py index 75df3dc97cf4..b6d64b98588d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py index a3dea0ab8ee6..4d20d077a968 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py index bcab36b1dbec..bb3fbbb1cd0d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py index 7fad1a2d3b87..49d7a6451afc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py index 5826bb1f15f1..828889908192 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py index b86b03be3591..709f0340d8d1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py @@ -13,8 +13,6 @@ from __future__ import annotations -import pprint -import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated @@ -29,9 +27,8 @@ class AnyOfColor(RootModel[Union[List[int], str]]): """ Any of RGB array, RGBA array, or hex string. """ - root: Union[List[int], str] = Field( - ... + ... ) def __getattr__(self, name): @@ -49,27 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - - diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py index a632d3c382d6..43dac2f68c23 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -import pprint -import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Optional from petstore_api.models.basque_pig import BasquePig @@ -30,9 +28,8 @@ class AnyOfPig(RootModel[Union[BasquePig, DanishPig]]): """ AnyOfPig """ - root: Union[BasquePig, DanishPig] = Field( - ... + ... ) def __getattr__(self, name): @@ -50,27 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - - diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py index 2607cb555897..3d5782d0d1ca 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py index b3502813e131..b303b82d0c34 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py index 40b76b10e2e8..39ac2a7e0f68 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py index 1ef35ed4290a..b012303f29aa 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py @@ -63,7 +63,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py index 6c414fe72920..c3990bb5d7a6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py index ef9d50223015..f556f04de30a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py index c81fd1e1c2ec..ba921d513ea5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py index e672f06cf876..45bcc225bc64 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py @@ -63,7 +63,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py index 2ab12e0b0b08..e593ba86fceb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py index a832b700194a..7430eb1787ca 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py index c08dfce51988..7f1cc8fde97f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py index a4397f923a4b..82f026964ae4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py index a0db951aaa5e..2cb3fc470658 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py index 5a12db40db07..0f854bacdd54 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py index 5197fe58ecc6..608ec222a231 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated @@ -24,6 +22,7 @@ COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] + class Color(RootModel[Union[List[int], str]]): """ RGB array, RGBA array, or hex string. @@ -47,26 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py index 17379d6ff774..15b76749fa90 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py index 33414bb2e4f6..981ef05acdd8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py index b2e7e8e9c884..27966281158f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py index eeed19fe0293..957868b83df0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py index 23c07b3cc8cd..cc65d8d533ab 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py index 424c25871dc8..6e8088cd9ad7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py index ab08540bc824..3dfe77ba0dd4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py index 339439a15b66..7b71819ff8c8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py index 4727cd9180b5..376c00c11a6e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py @@ -86,7 +86,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py index 5f3ded3bd569..733be97f744a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py index f38e8375d0f8..023b2041cec0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py @@ -166,7 +166,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py index bf9365e5b6bc..ac40e2c4bc11 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py index ee16b0236916..bc74f9eb3c61 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py index ed0e54ef78e5..1eae696b956c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py index 0fb22f81f548..cdf218a63f41 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py index 441022bc8977..5f6c1037346e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py index deac653ae358..5ea4c7ab3ded 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py index 2960e7f390c8..f3ed129507f1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py @@ -118,7 +118,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py index 970814db675e..9460f251a3e6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py index 658fdb690194..23a96af19797 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py index 05c5aef54690..b217b64eb254 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py index 0eb710f31a1c..fb5f216ebb44 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py index 7085980c441b..5a4a2a75237a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py index 37d9c2b8d285..a30be459a686 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py index c66bf1ab9772..b57c4c9d0f36 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated @@ -24,6 +22,7 @@ INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] + class IntOrString(RootModel[Union[int, str]]): """ IntOrString @@ -47,26 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py index 12892c065284..62563ea62df6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py index c5668fc1865f..7d3de9da442a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py index a8fee7d14e6f..26d0ec8a5b52 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py @@ -75,7 +75,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py index f2b040b8b0d9..7a18498a600a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -63,7 +63,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py index 2ed302bf3dda..7b27d759a90f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py index 5024a3748f4c..92b1f8db6a4c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py index c383206e7f01..df7da9890ada 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py index a50cfe4de892..a0fd00fd2afa 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py index 776597336558..c67a3848eb33 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py index 0a142fc76a55..822cf2e6cd24 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py index 9af5bd4422e9..d9fba557ebc0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py @@ -71,7 +71,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py index 97e118cfed4b..6d24c777f959 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py @@ -70,7 +70,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py index 4cbf63e51f9f..a1885ba09446 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py index 19e4e0a5b32f..632d1194dab0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py index 94e9f98754b1..427a8b48ea90 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py index bdbbebe0e1c4..e2b2780beece 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.enum_string1 import EnumString1 @@ -25,6 +23,7 @@ ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] + class OneOfEnumString(RootModel[Union[EnumString1, EnumString2]]): """ oneOf enum strings @@ -48,26 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py index a5c50a094a0b..d2c8d15aafdf 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py @@ -77,7 +77,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py index c137aa6b2f4f..c6b346a9fdc9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py index bab2f225fba6..29a10ce79b22 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py index ec9d1a338e3b..603a49deedd3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py index 1b3a5d2f2f4c..955b78f1c6d7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py index 0e1a9bf177f2..eaeed02c2863 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py index 6646e6d477cd..309874d6481b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig @@ -25,6 +23,7 @@ PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] + class Pig(RootModel[Union[BasquePig, DanishPig]]): """ Pig @@ -48,26 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py index f667018ed881..d601db0ad9a0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py index 7c16bfeec116..0a2b03923da7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py index 97e03f355280..2098b806eaf7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py index 11bab78a3c96..301804609080 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py index 5d0eb8d1225c..707204fbcd30 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py index 3665454efc1d..f75e2bbd25b8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py index b564e6d2ac79..0cdd8845df4a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py index 52d3347704b7..37759f82dfc5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py index 6c11409dee00..35e26e8b6f0c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py index ebbf9463952c..fd3b9b2c796a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py index 8319ec235809..cb3dfb6818fb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py @@ -74,7 +74,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py index 2a95cc94529f..f19810c852b5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py index 19ceec24044b..8066905e52e9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py index 39a1c0bbc375..15b92f1829bf 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.bathing import Bathing @@ -26,6 +24,7 @@ TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] + class TaskActivity(RootModel[Union[Bathing, Feeding, PoopCleaning]]): """ TaskActivity @@ -49,26 +48,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py index 1afe35f8f1ef..b137fea8e6de 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py index 91ea69de6d18..384a74097ba9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py index b8ae3f003698..d65b57c11542 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py index b239642e7959..20292e683cea 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py @@ -77,7 +77,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py index dbdf41c24874..b6adecb0dfdc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py index 17d63717565f..3bb414c6404b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 7e665d3a2739..fee88aee16f8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 863584646440..84e46fc2ea38 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py index 466d550ec22c..e792e29726bb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py index b47a215064eb..7474b3bb10c6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py @@ -65,7 +65,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py index c4da6d5004c5..b63d689801b2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py index 9c810c176590..3243abe84898 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py index a17e1f1dcb36..87cc8a3f2a2a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py index 75df3dc97cf4..b6d64b98588d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py index a3dea0ab8ee6..4d20d077a968 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py index bcab36b1dbec..bb3fbbb1cd0d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py index 7fad1a2d3b87..49d7a6451afc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py index 5826bb1f15f1..828889908192 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py index b86b03be3591..709f0340d8d1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py @@ -13,8 +13,6 @@ from __future__ import annotations -import pprint -import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated @@ -29,9 +27,8 @@ class AnyOfColor(RootModel[Union[List[int], str]]): """ Any of RGB array, RGBA array, or hex string. """ - root: Union[List[int], str] = Field( - ... + ... ) def __getattr__(self, name): @@ -49,27 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - - diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py index a632d3c382d6..43dac2f68c23 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -import pprint -import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Optional from petstore_api.models.basque_pig import BasquePig @@ -30,9 +28,8 @@ class AnyOfPig(RootModel[Union[BasquePig, DanishPig]]): """ AnyOfPig """ - root: Union[BasquePig, DanishPig] = Field( - ... + ... ) def __getattr__(self, name): @@ -50,27 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - - diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py index 2607cb555897..3d5782d0d1ca 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index b3502813e131..b303b82d0c34 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py index 40b76b10e2e8..39ac2a7e0f68 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py index 1ef35ed4290a..b012303f29aa 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py @@ -63,7 +63,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py index 6c414fe72920..c3990bb5d7a6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py index ef9d50223015..f556f04de30a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py index c81fd1e1c2ec..ba921d513ea5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py index e672f06cf876..45bcc225bc64 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py @@ -63,7 +63,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py index 2ab12e0b0b08..e593ba86fceb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/category.py b/samples/openapi3/client/petstore/python/petstore_api/models/category.py index a832b700194a..7430eb1787ca 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/category.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py index c08dfce51988..7f1cc8fde97f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py index a4397f923a4b..82f026964ae4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py index a0db951aaa5e..2cb3fc470658 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/client.py b/samples/openapi3/client/petstore/python/petstore_api/models/client.py index 5a12db40db07..0f854bacdd54 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/client.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/color.py b/samples/openapi3/client/petstore/python/petstore_api/models/color.py index 5197fe58ecc6..608ec222a231 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/color.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated @@ -24,6 +22,7 @@ COLOR_ONE_OF_SCHEMAS = ["List[int]", "str"] + class Color(RootModel[Union[List[int], str]]): """ RGB array, RGBA array, or hex string. @@ -47,26 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py index 17379d6ff774..15b76749fa90 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py index 33414bb2e4f6..981ef05acdd8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py index b2e7e8e9c884..27966281158f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py index eeed19fe0293..957868b83df0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py index 23c07b3cc8cd..cc65d8d533ab 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py index 424c25871dc8..6e8088cd9ad7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py @@ -80,7 +80,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py index ab08540bc824..3dfe77ba0dd4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py index 339439a15b66..7b71819ff8c8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py index 4727cd9180b5..376c00c11a6e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py @@ -86,7 +86,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py index 5f3ded3bd569..733be97f744a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index f38e8375d0f8..023b2041cec0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -166,7 +166,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py index bf9365e5b6bc..ac40e2c4bc11 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file.py b/samples/openapi3/client/petstore/python/petstore_api/models/file.py index ee16b0236916..bc74f9eb3c61 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py index ed0e54ef78e5..1eae696b956c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py index 0fb22f81f548..cdf218a63f41 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py index 441022bc8977..5f6c1037346e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py index deac653ae358..5ea4c7ab3ded 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py index 2960e7f390c8..f3ed129507f1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py @@ -118,7 +118,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py index 970814db675e..9460f251a3e6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py index 658fdb690194..23a96af19797 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py index 05c5aef54690..b217b64eb254 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/info.py b/samples/openapi3/client/petstore/python/petstore_api/models/info.py index 0eb710f31a1c..fb5f216ebb44 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/info.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py index 7085980c441b..5a4a2a75237a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py index 37d9c2b8d285..a30be459a686 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py index c66bf1ab9772..b57c4c9d0f36 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated @@ -24,6 +22,7 @@ INTORSTRING_ONE_OF_SCHEMAS = ["int", "str"] + class IntOrString(RootModel[Union[int, str]]): """ IntOrString @@ -47,26 +46,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py index 12892c065284..62563ea62df6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index c5668fc1865f..7d3de9da442a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py index a8fee7d14e6f..26d0ec8a5b52 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py @@ -75,7 +75,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index f2b040b8b0d9..7a18498a600a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -63,7 +63,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py index 2ed302bf3dda..7b27d759a90f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py index 5024a3748f4c..92b1f8db6a4c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py index c383206e7f01..df7da9890ada 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py index a50cfe4de892..a0fd00fd2afa 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py index 776597336558..c67a3848eb33 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/name.py b/samples/openapi3/client/petstore/python/petstore_api/models/name.py index 0a142fc76a55..822cf2e6cd24 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/name.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py index 9af5bd4422e9..d9fba557ebc0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py @@ -71,7 +71,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py index 97e118cfed4b..6d24c777f959 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py @@ -70,7 +70,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py index 4cbf63e51f9f..a1885ba09446 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py index 19e4e0a5b32f..632d1194dab0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py index 94e9f98754b1..427a8b48ea90 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py index bdbbebe0e1c4..e2b2780beece 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.enum_string1 import EnumString1 @@ -25,6 +23,7 @@ ONEOFENUMSTRING_ONE_OF_SCHEMAS = ["EnumString1", "EnumString2"] + class OneOfEnumString(RootModel[Union[EnumString1, EnumString2]]): """ oneOf enum strings @@ -48,26 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/order.py b/samples/openapi3/client/petstore/python/petstore_api/models/order.py index a5c50a094a0b..d2c8d15aafdf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -77,7 +77,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py index c137aa6b2f4f..c6b346a9fdc9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py index bab2f225fba6..29a10ce79b22 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py index ec9d1a338e3b..603a49deedd3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py index 1b3a5d2f2f4c..955b78f1c6d7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py index 0e1a9bf177f2..eaeed02c2863 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -79,7 +79,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py index 6646e6d477cd..309874d6481b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig @@ -25,6 +23,7 @@ PIG_ONE_OF_SCHEMAS = ["BasquePig", "DanishPig"] + class Pig(RootModel[Union[BasquePig, DanishPig]]): """ Pig @@ -48,26 +47,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py index f667018ed881..d601db0ad9a0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py index 7c16bfeec116..0a2b03923da7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py @@ -82,7 +82,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py index 97e03f355280..2098b806eaf7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py index 11bab78a3c96..301804609080 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py index 5d0eb8d1225c..707204fbcd30 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py @@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py index 3665454efc1d..f75e2bbd25b8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py index b564e6d2ac79..0cdd8845df4a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py index 52d3347704b7..37759f82dfc5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py index 6c11409dee00..35e26e8b6f0c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py index ebbf9463952c..fd3b9b2c796a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py index 8319ec235809..cb3dfb6818fb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py @@ -74,7 +74,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py index 2a95cc94529f..f19810c852b5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task.py b/samples/openapi3/client/petstore/python/petstore_api/models/task.py index 19ceec24044b..8066905e52e9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task.py @@ -61,7 +61,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py index 39a1c0bbc375..15b92f1829bf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py @@ -13,8 +13,6 @@ from __future__ import annotations -import json -import pprint from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.bathing import Bathing @@ -26,6 +24,7 @@ TASKACTIVITY_ONE_OF_SCHEMAS = ["Bathing", "Feeding", "PoopCleaning"] + class TaskActivity(RootModel[Union[Bathing, Feeding, PoopCleaning]]): """ TaskActivity @@ -49,26 +48,4 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") - @classmethod - def from_dict(cls, obj: Dict[str, Any]) -> Self: - """Returns the object represented by the Dict""" - return cls.model_validate(obj, strict=True) - - @classmethod - def from_json(cls, json_str: str) -> Self: - """Returns the object represented by the json string""" - return cls.model_validate_json(json_str) - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return self.model_dump_json(by_alias=True, exclude_none=True) - - def to_dict(self) -> Dict[str, Any]: - """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.model_dump(by_alias=True, mode="json")) - diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py index 1afe35f8f1ef..b137fea8e6de 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py index 91ea69de6d18..384a74097ba9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py index b8ae3f003698..d65b57c11542 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py index b239642e7959..20292e683cea 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py @@ -77,7 +77,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py index dbdf41c24874..b6adecb0dfdc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py index 17d63717565f..3bb414c6404b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 7e665d3a2739..fee88aee16f8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -59,7 +59,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 863584646440..84e46fc2ea38 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py index 466d550ec22c..e792e29726bb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -58,7 +58,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/user.py b/samples/openapi3/client/petstore/python/petstore_api/models/user.py index b47a215064eb..7474b3bb10c6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/user.py @@ -65,7 +65,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py index c4da6d5004c5..b63d689801b2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py @@ -62,7 +62,7 @@ def to_dict(self) -> Dict[str, Any]: def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) + return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) From a925bbdffea0ba083df9056cf97cea26750855d4 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Mon, 16 Feb 2026 13:07:06 +0100 Subject: [PATCH 07/13] [REF] model_generic.mustache --- .../src/main/resources/python/model_anyof.mustache | 2 +- .../src/main/resources/python/model_generic.mustache | 10 +++++----- .../openapi_client/models/bird.py | 10 +++++----- .../openapi_client/models/category.py | 10 +++++----- .../openapi_client/models/data_query.py | 10 +++++----- .../openapi_client/models/default_value.py | 10 +++++----- .../openapi_client/models/number_properties_only.py | 10 +++++----- .../openapi_client/models/pet.py | 10 +++++----- .../openapi_client/models/query.py | 10 +++++----- .../openapi_client/models/tag.py | 10 +++++----- .../test_form_object_multipart_request_marker.py | 10 +++++----- ...xplode_true_object_all_of_query_object_parameter.py | 10 +++++----- ...explode_true_array_string_query_object_parameter.py | 10 +++++----- .../echo_api/python/openapi_client/models/bird.py | 10 +++++----- .../echo_api/python/openapi_client/models/category.py | 10 +++++----- .../python/openapi_client/models/data_query.py | 10 +++++----- .../python/openapi_client/models/default_value.py | 10 +++++----- .../openapi_client/models/number_properties_only.py | 10 +++++----- .../echo_api/python/openapi_client/models/pet.py | 10 +++++----- .../echo_api/python/openapi_client/models/query.py | 10 +++++----- .../echo_api/python/openapi_client/models/tag.py | 10 +++++----- .../test_form_object_multipart_request_marker.py | 10 +++++----- ...xplode_true_object_all_of_query_object_parameter.py | 10 +++++----- ...explode_true_array_string_query_object_parameter.py | 10 +++++----- .../models/additional_properties_any_type.py | 10 +++++----- .../petstore_api/models/additional_properties_class.py | 10 +++++----- .../models/additional_properties_object.py | 10 +++++----- .../additional_properties_with_description_only.py | 10 +++++----- .../petstore_api/models/all_of_super_model.py | 10 +++++----- .../petstore_api/models/all_of_with_single_ref.py | 10 +++++----- .../python-aiohttp/petstore_api/models/animal.py | 10 +++++----- .../python-aiohttp/petstore_api/models/any_of_color.py | 2 +- .../python-aiohttp/petstore_api/models/any_of_pig.py | 2 +- .../petstore_api/models/array_of_array_of_model.py | 10 +++++----- .../models/array_of_array_of_number_only.py | 10 +++++----- .../petstore_api/models/array_of_number_only.py | 10 +++++----- .../python-aiohttp/petstore_api/models/array_test.py | 10 +++++----- .../petstore_api/models/base_discriminator.py | 10 +++++----- .../python-aiohttp/petstore_api/models/basque_pig.py | 10 +++++----- .../python-aiohttp/petstore_api/models/bathing.py | 10 +++++----- .../petstore_api/models/capitalization.py | 10 +++++----- .../petstore/python-aiohttp/petstore_api/models/cat.py | 10 +++++----- .../python-aiohttp/petstore_api/models/category.py | 10 +++++----- .../petstore_api/models/circular_all_of_ref.py | 10 +++++----- .../petstore_api/models/circular_reference_model.py | 10 +++++----- .../python-aiohttp/petstore_api/models/class_model.py | 10 +++++----- .../python-aiohttp/petstore_api/models/client.py | 10 +++++----- .../python-aiohttp/petstore_api/models/creature.py | 10 +++++----- .../petstore_api/models/creature_info.py | 10 +++++----- .../python-aiohttp/petstore_api/models/danish_pig.py | 10 +++++----- .../petstore_api/models/deprecated_object.py | 10 +++++----- .../petstore_api/models/discriminator_all_of_sub.py | 10 +++++----- .../petstore_api/models/discriminator_all_of_super.py | 10 +++++----- .../petstore/python-aiohttp/petstore_api/models/dog.py | 10 +++++----- .../python-aiohttp/petstore_api/models/dummy_model.py | 10 +++++----- .../python-aiohttp/petstore_api/models/enum_arrays.py | 10 +++++----- .../petstore_api/models/enum_ref_with_default_value.py | 10 +++++----- .../python-aiohttp/petstore_api/models/enum_test.py | 10 +++++----- .../python-aiohttp/petstore_api/models/feeding.py | 10 +++++----- .../python-aiohttp/petstore_api/models/file.py | 10 +++++----- .../petstore_api/models/file_schema_test_class.py | 10 +++++----- .../python-aiohttp/petstore_api/models/first_ref.py | 10 +++++----- .../petstore/python-aiohttp/petstore_api/models/foo.py | 10 +++++----- .../petstore_api/models/foo_get_default_response.py | 10 +++++----- .../python-aiohttp/petstore_api/models/format_test.py | 10 +++++----- .../petstore_api/models/has_only_read_only.py | 10 +++++----- .../petstore_api/models/health_check_result.py | 10 +++++----- .../python-aiohttp/petstore_api/models/hunting_dog.py | 10 +++++----- .../python-aiohttp/petstore_api/models/info.py | 10 +++++----- .../petstore_api/models/inner_dict_with_property.py | 10 +++++----- .../python-aiohttp/petstore_api/models/input_all_of.py | 10 +++++----- .../python-aiohttp/petstore_api/models/list_class.py | 10 +++++----- .../petstore_api/models/map_of_array_of_model.py | 10 +++++----- .../python-aiohttp/petstore_api/models/map_test.py | 10 +++++----- ...mixed_properties_and_additional_properties_class.py | 10 +++++----- .../petstore_api/models/model200_response.py | 10 +++++----- .../petstore_api/models/model_api_response.py | 10 +++++----- .../python-aiohttp/petstore_api/models/model_field.py | 10 +++++----- .../python-aiohttp/petstore_api/models/model_return.py | 10 +++++----- .../python-aiohttp/petstore_api/models/multi_arrays.py | 10 +++++----- .../python-aiohttp/petstore_api/models/name.py | 10 +++++----- .../petstore_api/models/nullable_class.py | 10 +++++----- .../petstore_api/models/nullable_property.py | 10 +++++----- .../python-aiohttp/petstore_api/models/number_only.py | 10 +++++----- .../models/object_to_test_additional_properties.py | 10 +++++----- .../models/object_with_deprecated_fields.py | 10 +++++----- .../python-aiohttp/petstore_api/models/order.py | 10 +++++----- .../petstore_api/models/outer_composite.py | 10 +++++----- .../models/outer_object_with_enum_property.py | 10 +++++----- .../python-aiohttp/petstore_api/models/parent.py | 10 +++++----- .../petstore_api/models/parent_with_optional_dict.py | 10 +++++----- .../petstore/python-aiohttp/petstore_api/models/pet.py | 10 +++++----- .../python-aiohttp/petstore_api/models/pony_sizes.py | 10 +++++----- .../petstore_api/models/poop_cleaning.py | 10 +++++----- .../petstore_api/models/primitive_string.py | 10 +++++----- .../python-aiohttp/petstore_api/models/property_map.py | 10 +++++----- .../petstore_api/models/property_name_collision.py | 10 +++++----- .../petstore_api/models/read_only_first.py | 10 +++++----- .../petstore_api/models/second_circular_all_of_ref.py | 10 +++++----- .../python-aiohttp/petstore_api/models/second_ref.py | 10 +++++----- .../petstore_api/models/self_reference_model.py | 10 +++++----- .../petstore_api/models/special_model_name.py | 10 +++++----- .../python-aiohttp/petstore_api/models/special_name.py | 10 +++++----- .../petstore/python-aiohttp/petstore_api/models/tag.py | 10 +++++----- .../python-aiohttp/petstore_api/models/task.py | 10 +++++----- .../test_error_responses_with_model400_response.py | 10 +++++----- .../test_error_responses_with_model404_response.py | 10 +++++----- ...st_inline_freeform_additional_properties_request.py | 10 +++++----- .../models/test_model_with_enum_default.py | 10 +++++----- ...est_object_for_multipart_requests_request_marker.py | 10 +++++----- .../python-aiohttp/petstore_api/models/tiger.py | 10 +++++----- ...named_dict_with_additional_model_list_properties.py | 10 +++++----- ...amed_dict_with_additional_string_list_properties.py | 10 +++++----- ...d_file_with_additional_properties_request_object.py | 10 +++++----- .../python-aiohttp/petstore_api/models/user.py | 10 +++++----- .../petstore_api/models/with_nested_one_of.py | 10 +++++----- .../models/additional_properties_any_type.py | 10 +++++----- .../petstore_api/models/additional_properties_class.py | 10 +++++----- .../models/additional_properties_object.py | 10 +++++----- .../additional_properties_with_description_only.py | 10 +++++----- .../petstore_api/models/all_of_super_model.py | 10 +++++----- .../petstore_api/models/all_of_with_single_ref.py | 10 +++++----- .../python-httpx/petstore_api/models/animal.py | 10 +++++----- .../python-httpx/petstore_api/models/any_of_color.py | 2 +- .../python-httpx/petstore_api/models/any_of_pig.py | 2 +- .../petstore_api/models/array_of_array_of_model.py | 10 +++++----- .../models/array_of_array_of_number_only.py | 10 +++++----- .../petstore_api/models/array_of_number_only.py | 10 +++++----- .../python-httpx/petstore_api/models/array_test.py | 10 +++++----- .../petstore_api/models/base_discriminator.py | 10 +++++----- .../python-httpx/petstore_api/models/basque_pig.py | 10 +++++----- .../python-httpx/petstore_api/models/bathing.py | 10 +++++----- .../python-httpx/petstore_api/models/capitalization.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/cat.py | 10 +++++----- .../python-httpx/petstore_api/models/category.py | 10 +++++----- .../petstore_api/models/circular_all_of_ref.py | 10 +++++----- .../petstore_api/models/circular_reference_model.py | 10 +++++----- .../python-httpx/petstore_api/models/class_model.py | 10 +++++----- .../python-httpx/petstore_api/models/client.py | 10 +++++----- .../python-httpx/petstore_api/models/creature.py | 10 +++++----- .../python-httpx/petstore_api/models/creature_info.py | 10 +++++----- .../python-httpx/petstore_api/models/danish_pig.py | 10 +++++----- .../petstore_api/models/deprecated_object.py | 10 +++++----- .../petstore_api/models/discriminator_all_of_sub.py | 10 +++++----- .../petstore_api/models/discriminator_all_of_super.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/dog.py | 10 +++++----- .../python-httpx/petstore_api/models/dummy_model.py | 10 +++++----- .../python-httpx/petstore_api/models/enum_arrays.py | 10 +++++----- .../petstore_api/models/enum_ref_with_default_value.py | 10 +++++----- .../python-httpx/petstore_api/models/enum_test.py | 10 +++++----- .../python-httpx/petstore_api/models/feeding.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/file.py | 10 +++++----- .../petstore_api/models/file_schema_test_class.py | 10 +++++----- .../python-httpx/petstore_api/models/first_ref.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/foo.py | 10 +++++----- .../petstore_api/models/foo_get_default_response.py | 10 +++++----- .../python-httpx/petstore_api/models/format_test.py | 10 +++++----- .../petstore_api/models/has_only_read_only.py | 10 +++++----- .../petstore_api/models/health_check_result.py | 10 +++++----- .../python-httpx/petstore_api/models/hunting_dog.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/info.py | 10 +++++----- .../petstore_api/models/inner_dict_with_property.py | 10 +++++----- .../python-httpx/petstore_api/models/input_all_of.py | 10 +++++----- .../python-httpx/petstore_api/models/list_class.py | 10 +++++----- .../petstore_api/models/map_of_array_of_model.py | 10 +++++----- .../python-httpx/petstore_api/models/map_test.py | 10 +++++----- ...mixed_properties_and_additional_properties_class.py | 10 +++++----- .../petstore_api/models/model200_response.py | 10 +++++----- .../petstore_api/models/model_api_response.py | 10 +++++----- .../python-httpx/petstore_api/models/model_field.py | 10 +++++----- .../python-httpx/petstore_api/models/model_return.py | 10 +++++----- .../python-httpx/petstore_api/models/multi_arrays.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/name.py | 10 +++++----- .../python-httpx/petstore_api/models/nullable_class.py | 10 +++++----- .../petstore_api/models/nullable_property.py | 10 +++++----- .../python-httpx/petstore_api/models/number_only.py | 10 +++++----- .../models/object_to_test_additional_properties.py | 10 +++++----- .../models/object_with_deprecated_fields.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/order.py | 10 +++++----- .../petstore_api/models/outer_composite.py | 10 +++++----- .../models/outer_object_with_enum_property.py | 10 +++++----- .../python-httpx/petstore_api/models/parent.py | 10 +++++----- .../petstore_api/models/parent_with_optional_dict.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/pet.py | 10 +++++----- .../python-httpx/petstore_api/models/pony_sizes.py | 10 +++++----- .../python-httpx/petstore_api/models/poop_cleaning.py | 10 +++++----- .../petstore_api/models/primitive_string.py | 10 +++++----- .../python-httpx/petstore_api/models/property_map.py | 10 +++++----- .../petstore_api/models/property_name_collision.py | 10 +++++----- .../petstore_api/models/read_only_first.py | 10 +++++----- .../petstore_api/models/second_circular_all_of_ref.py | 10 +++++----- .../python-httpx/petstore_api/models/second_ref.py | 10 +++++----- .../petstore_api/models/self_reference_model.py | 10 +++++----- .../petstore_api/models/special_model_name.py | 10 +++++----- .../python-httpx/petstore_api/models/special_name.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/tag.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/task.py | 10 +++++----- .../test_error_responses_with_model400_response.py | 10 +++++----- .../test_error_responses_with_model404_response.py | 10 +++++----- ...st_inline_freeform_additional_properties_request.py | 10 +++++----- .../models/test_model_with_enum_default.py | 10 +++++----- ...est_object_for_multipart_requests_request_marker.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/tiger.py | 10 +++++----- ...named_dict_with_additional_model_list_properties.py | 10 +++++----- ...amed_dict_with_additional_string_list_properties.py | 10 +++++----- ...d_file_with_additional_properties_request_object.py | 10 +++++----- .../petstore/python-httpx/petstore_api/models/user.py | 10 +++++----- .../petstore_api/models/with_nested_one_of.py | 10 +++++----- .../models/additional_properties_any_type.py | 10 +++++----- .../petstore_api/models/additional_properties_class.py | 10 +++++----- .../models/additional_properties_object.py | 10 +++++----- .../additional_properties_with_description_only.py | 10 +++++----- .../petstore_api/models/all_of_super_model.py | 10 +++++----- .../petstore_api/models/all_of_with_single_ref.py | 10 +++++----- .../python-lazyImports/petstore_api/models/animal.py | 10 +++++----- .../petstore_api/models/any_of_color.py | 2 +- .../petstore_api/models/any_of_pig.py | 2 +- .../petstore_api/models/array_of_array_of_model.py | 10 +++++----- .../models/array_of_array_of_number_only.py | 10 +++++----- .../petstore_api/models/array_of_number_only.py | 10 +++++----- .../petstore_api/models/array_test.py | 10 +++++----- .../petstore_api/models/base_discriminator.py | 10 +++++----- .../petstore_api/models/basque_pig.py | 10 +++++----- .../python-lazyImports/petstore_api/models/bathing.py | 10 +++++----- .../petstore_api/models/capitalization.py | 10 +++++----- .../python-lazyImports/petstore_api/models/cat.py | 10 +++++----- .../python-lazyImports/petstore_api/models/category.py | 10 +++++----- .../petstore_api/models/circular_all_of_ref.py | 10 +++++----- .../petstore_api/models/circular_reference_model.py | 10 +++++----- .../petstore_api/models/class_model.py | 10 +++++----- .../python-lazyImports/petstore_api/models/client.py | 10 +++++----- .../python-lazyImports/petstore_api/models/creature.py | 10 +++++----- .../petstore_api/models/creature_info.py | 10 +++++----- .../petstore_api/models/danish_pig.py | 10 +++++----- .../petstore_api/models/deprecated_object.py | 10 +++++----- .../petstore_api/models/discriminator_all_of_sub.py | 10 +++++----- .../petstore_api/models/discriminator_all_of_super.py | 10 +++++----- .../python-lazyImports/petstore_api/models/dog.py | 10 +++++----- .../petstore_api/models/dummy_model.py | 10 +++++----- .../petstore_api/models/enum_arrays.py | 10 +++++----- .../petstore_api/models/enum_ref_with_default_value.py | 10 +++++----- .../petstore_api/models/enum_test.py | 10 +++++----- .../python-lazyImports/petstore_api/models/feeding.py | 10 +++++----- .../python-lazyImports/petstore_api/models/file.py | 10 +++++----- .../petstore_api/models/file_schema_test_class.py | 10 +++++----- .../petstore_api/models/first_ref.py | 10 +++++----- .../python-lazyImports/petstore_api/models/foo.py | 10 +++++----- .../petstore_api/models/foo_get_default_response.py | 10 +++++----- .../petstore_api/models/format_test.py | 10 +++++----- .../petstore_api/models/has_only_read_only.py | 10 +++++----- .../petstore_api/models/health_check_result.py | 10 +++++----- .../petstore_api/models/hunting_dog.py | 10 +++++----- .../python-lazyImports/petstore_api/models/info.py | 10 +++++----- .../petstore_api/models/inner_dict_with_property.py | 10 +++++----- .../petstore_api/models/input_all_of.py | 10 +++++----- .../petstore_api/models/list_class.py | 10 +++++----- .../petstore_api/models/map_of_array_of_model.py | 10 +++++----- .../python-lazyImports/petstore_api/models/map_test.py | 10 +++++----- ...mixed_properties_and_additional_properties_class.py | 10 +++++----- .../petstore_api/models/model200_response.py | 10 +++++----- .../petstore_api/models/model_api_response.py | 10 +++++----- .../petstore_api/models/model_field.py | 10 +++++----- .../petstore_api/models/model_return.py | 10 +++++----- .../petstore_api/models/multi_arrays.py | 10 +++++----- .../python-lazyImports/petstore_api/models/name.py | 10 +++++----- .../petstore_api/models/nullable_class.py | 10 +++++----- .../petstore_api/models/nullable_property.py | 10 +++++----- .../petstore_api/models/number_only.py | 10 +++++----- .../models/object_to_test_additional_properties.py | 10 +++++----- .../models/object_with_deprecated_fields.py | 10 +++++----- .../python-lazyImports/petstore_api/models/order.py | 10 +++++----- .../petstore_api/models/outer_composite.py | 10 +++++----- .../models/outer_object_with_enum_property.py | 10 +++++----- .../python-lazyImports/petstore_api/models/parent.py | 10 +++++----- .../petstore_api/models/parent_with_optional_dict.py | 10 +++++----- .../python-lazyImports/petstore_api/models/pet.py | 10 +++++----- .../petstore_api/models/pony_sizes.py | 10 +++++----- .../petstore_api/models/poop_cleaning.py | 10 +++++----- .../petstore_api/models/primitive_string.py | 10 +++++----- .../petstore_api/models/property_map.py | 10 +++++----- .../petstore_api/models/property_name_collision.py | 10 +++++----- .../petstore_api/models/read_only_first.py | 10 +++++----- .../petstore_api/models/second_circular_all_of_ref.py | 10 +++++----- .../petstore_api/models/second_ref.py | 10 +++++----- .../petstore_api/models/self_reference_model.py | 10 +++++----- .../petstore_api/models/special_model_name.py | 10 +++++----- .../petstore_api/models/special_name.py | 10 +++++----- .../python-lazyImports/petstore_api/models/tag.py | 10 +++++----- .../python-lazyImports/petstore_api/models/task.py | 10 +++++----- .../test_error_responses_with_model400_response.py | 10 +++++----- .../test_error_responses_with_model404_response.py | 10 +++++----- ...st_inline_freeform_additional_properties_request.py | 10 +++++----- .../models/test_model_with_enum_default.py | 10 +++++----- ...est_object_for_multipart_requests_request_marker.py | 10 +++++----- .../python-lazyImports/petstore_api/models/tiger.py | 10 +++++----- ...named_dict_with_additional_model_list_properties.py | 10 +++++----- ...amed_dict_with_additional_string_list_properties.py | 10 +++++----- ...d_file_with_additional_properties_request_object.py | 10 +++++----- .../python-lazyImports/petstore_api/models/user.py | 10 +++++----- .../petstore_api/models/with_nested_one_of.py | 10 +++++----- .../models/additional_properties_any_type.py | 10 +++++----- .../petstore_api/models/additional_properties_class.py | 10 +++++----- .../models/additional_properties_object.py | 10 +++++----- .../additional_properties_with_description_only.py | 10 +++++----- .../python/petstore_api/models/all_of_super_model.py | 10 +++++----- .../petstore_api/models/all_of_with_single_ref.py | 10 +++++----- .../petstore/python/petstore_api/models/animal.py | 10 +++++----- .../python/petstore_api/models/any_of_color.py | 2 +- .../petstore/python/petstore_api/models/any_of_pig.py | 2 +- .../petstore_api/models/array_of_array_of_model.py | 10 +++++----- .../models/array_of_array_of_number_only.py | 10 +++++----- .../python/petstore_api/models/array_of_number_only.py | 10 +++++----- .../petstore/python/petstore_api/models/array_test.py | 10 +++++----- .../python/petstore_api/models/base_discriminator.py | 10 +++++----- .../petstore/python/petstore_api/models/basque_pig.py | 10 +++++----- .../petstore/python/petstore_api/models/bathing.py | 10 +++++----- .../python/petstore_api/models/capitalization.py | 10 +++++----- .../client/petstore/python/petstore_api/models/cat.py | 10 +++++----- .../petstore/python/petstore_api/models/category.py | 10 +++++----- .../python/petstore_api/models/circular_all_of_ref.py | 10 +++++----- .../petstore_api/models/circular_reference_model.py | 10 +++++----- .../petstore/python/petstore_api/models/class_model.py | 10 +++++----- .../petstore/python/petstore_api/models/client.py | 10 +++++----- .../petstore/python/petstore_api/models/creature.py | 10 +++++----- .../python/petstore_api/models/creature_info.py | 10 +++++----- .../petstore/python/petstore_api/models/danish_pig.py | 10 +++++----- .../python/petstore_api/models/deprecated_object.py | 10 +++++----- .../petstore_api/models/discriminator_all_of_sub.py | 10 +++++----- .../petstore_api/models/discriminator_all_of_super.py | 10 +++++----- .../client/petstore/python/petstore_api/models/dog.py | 10 +++++----- .../petstore/python/petstore_api/models/dummy_model.py | 10 +++++----- .../petstore/python/petstore_api/models/enum_arrays.py | 10 +++++----- .../petstore_api/models/enum_ref_with_default_value.py | 10 +++++----- .../petstore/python/petstore_api/models/enum_test.py | 10 +++++----- .../petstore/python/petstore_api/models/feeding.py | 10 +++++----- .../client/petstore/python/petstore_api/models/file.py | 10 +++++----- .../petstore_api/models/file_schema_test_class.py | 10 +++++----- .../petstore/python/petstore_api/models/first_ref.py | 10 +++++----- .../client/petstore/python/petstore_api/models/foo.py | 10 +++++----- .../petstore_api/models/foo_get_default_response.py | 10 +++++----- .../petstore/python/petstore_api/models/format_test.py | 10 +++++----- .../python/petstore_api/models/has_only_read_only.py | 10 +++++----- .../python/petstore_api/models/health_check_result.py | 10 +++++----- .../petstore/python/petstore_api/models/hunting_dog.py | 10 +++++----- .../client/petstore/python/petstore_api/models/info.py | 10 +++++----- .../petstore_api/models/inner_dict_with_property.py | 10 +++++----- .../python/petstore_api/models/input_all_of.py | 10 +++++----- .../petstore/python/petstore_api/models/list_class.py | 10 +++++----- .../petstore_api/models/map_of_array_of_model.py | 10 +++++----- .../petstore/python/petstore_api/models/map_test.py | 10 +++++----- ...mixed_properties_and_additional_properties_class.py | 10 +++++----- .../python/petstore_api/models/model200_response.py | 10 +++++----- .../python/petstore_api/models/model_api_response.py | 10 +++++----- .../petstore/python/petstore_api/models/model_field.py | 10 +++++----- .../python/petstore_api/models/model_return.py | 10 +++++----- .../python/petstore_api/models/multi_arrays.py | 10 +++++----- .../client/petstore/python/petstore_api/models/name.py | 10 +++++----- .../python/petstore_api/models/nullable_class.py | 10 +++++----- .../python/petstore_api/models/nullable_property.py | 10 +++++----- .../petstore/python/petstore_api/models/number_only.py | 10 +++++----- .../models/object_to_test_additional_properties.py | 10 +++++----- .../models/object_with_deprecated_fields.py | 10 +++++----- .../petstore/python/petstore_api/models/order.py | 10 +++++----- .../python/petstore_api/models/outer_composite.py | 10 +++++----- .../models/outer_object_with_enum_property.py | 10 +++++----- .../petstore/python/petstore_api/models/parent.py | 10 +++++----- .../petstore_api/models/parent_with_optional_dict.py | 10 +++++----- .../client/petstore/python/petstore_api/models/pet.py | 10 +++++----- .../petstore/python/petstore_api/models/pony_sizes.py | 10 +++++----- .../python/petstore_api/models/poop_cleaning.py | 10 +++++----- .../python/petstore_api/models/primitive_string.py | 10 +++++----- .../python/petstore_api/models/property_map.py | 10 +++++----- .../petstore_api/models/property_name_collision.py | 10 +++++----- .../python/petstore_api/models/read_only_first.py | 10 +++++----- .../petstore_api/models/second_circular_all_of_ref.py | 10 +++++----- .../petstore/python/petstore_api/models/second_ref.py | 10 +++++----- .../python/petstore_api/models/self_reference_model.py | 10 +++++----- .../python/petstore_api/models/special_model_name.py | 10 +++++----- .../python/petstore_api/models/special_name.py | 10 +++++----- .../client/petstore/python/petstore_api/models/tag.py | 10 +++++----- .../client/petstore/python/petstore_api/models/task.py | 10 +++++----- .../test_error_responses_with_model400_response.py | 10 +++++----- .../test_error_responses_with_model404_response.py | 10 +++++----- ...st_inline_freeform_additional_properties_request.py | 10 +++++----- .../models/test_model_with_enum_default.py | 10 +++++----- ...est_object_for_multipart_requests_request_marker.py | 10 +++++----- .../petstore/python/petstore_api/models/tiger.py | 10 +++++----- ...named_dict_with_additional_model_list_properties.py | 10 +++++----- ...amed_dict_with_additional_string_list_properties.py | 10 +++++----- ...d_file_with_additional_properties_request_object.py | 10 +++++----- .../client/petstore/python/petstore_api/models/user.py | 10 +++++----- .../python/petstore_api/models/with_nested_one_of.py | 10 +++++----- 392 files changed, 1924 insertions(+), 1924 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index e0f5246a7256..703a7e007e1d 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -5,9 +5,9 @@ from __future__ import annotations {{#vendorExtensions.x-py-model-imports}} {{{.}}} {{/vendorExtensions.x-py-model-imports}} +from pydantic import Field, RootModel from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field, RootModel {{#lambda.uppercase}}{{{classname}}}{{/lambda.uppercase}}_ANY_OF_SCHEMAS = [{{#anyOf}}"{{.}}"{{^-last}}, {{/-last}}{{/anyOf}}] diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index 18f3a8894715..695dc754c333 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -166,17 +166,17 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) {{#vendorExtensions.x-py-postponed-model-imports.size}} diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py index 1a2f2d798c10..e461503b2a43 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py index 9370c2c6e41e..3a9048ae8ee4 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py index 63f2fd374a96..528ef0aedba1 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py index b14289b63af4..91a72d879190 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py index 7e47285007bd..f7431648d842 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py index 0ab779eea809..1cb31fc6ee44 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py @@ -68,17 +68,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py index 5066d9aeeb90..bd5b78711bc7 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py @@ -63,17 +63,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py index 566558fafa64..fdaa35e73a13 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py index 0c24a9c487f1..07ba24f8b1e6 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 653d4b7154d7..dca62df92f94 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 82ab35a69c58..660e468d97f8 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/bird.py b/samples/client/echo_api/python/openapi_client/models/bird.py index 1a2f2d798c10..e461503b2a43 100644 --- a/samples/client/echo_api/python/openapi_client/models/bird.py +++ b/samples/client/echo_api/python/openapi_client/models/bird.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/category.py b/samples/client/echo_api/python/openapi_client/models/category.py index 9370c2c6e41e..3a9048ae8ee4 100644 --- a/samples/client/echo_api/python/openapi_client/models/category.py +++ b/samples/client/echo_api/python/openapi_client/models/category.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/data_query.py b/samples/client/echo_api/python/openapi_client/models/data_query.py index 63f2fd374a96..528ef0aedba1 100644 --- a/samples/client/echo_api/python/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python/openapi_client/models/data_query.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/default_value.py b/samples/client/echo_api/python/openapi_client/models/default_value.py index b14289b63af4..91a72d879190 100644 --- a/samples/client/echo_api/python/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python/openapi_client/models/default_value.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py index 7e47285007bd..f7431648d842 100644 --- a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/pet.py b/samples/client/echo_api/python/openapi_client/models/pet.py index 0ab779eea809..1cb31fc6ee44 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -68,17 +68,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/query.py b/samples/client/echo_api/python/openapi_client/models/query.py index 5066d9aeeb90..bd5b78711bc7 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -63,17 +63,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/tag.py b/samples/client/echo_api/python/openapi_client/models/tag.py index 566558fafa64..fdaa35e73a13 100644 --- a/samples/client/echo_api/python/openapi_client/models/tag.py +++ b/samples/client/echo_api/python/openapi_client/models/tag.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py index 0c24a9c487f1..07ba24f8b1e6 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 653d4b7154d7..dca62df92f94 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 82ab35a69c58..660e468d97f8 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py index 3243abe84898..3bb1ccc0c8c1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py index ce0a36181d9c..f3f9fc8a4915 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py index b6d64b98588d..62484c169307 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py index 4d20d077a968..14c7b7ef0ace 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py index c47abd4a04bd..deefaa35093b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py index 2356cd8dd8e2..4cd64834d063 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py index e9c7c3d1fa1d..1fcaf35cedf0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py index 709f0340d8d1..970bd7582756 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py @@ -16,9 +16,9 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated +from pydantic import Field, RootModel from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field, RootModel ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py index 43dac2f68c23..a90287e17b02 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py @@ -17,9 +17,9 @@ from typing import Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig +from pydantic import Field, RootModel from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field, RootModel ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py index 2b46cb9082e0..3f190edb1cd2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py index dd845d845682..0fa78c8019e0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py index 331547535ef8..1354387153c2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py index 89662a882d07..b8b27efcac95 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py index 83ce91145b77..e7d393542f0c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py index ee8182d48596..e714cc8635f9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py index 3bb60f92db62..868d38a01d4a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py index 342ad31326eb..5a86254c53fe 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py index 2dd0d3274708..8f781a6de0ca 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py index b62765b8abe9..695375f29b97 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py index 0d01949fd3a7..7a9c7ca4fd80 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py index 420a7700bc53..73b0755c0247 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py index 8deb7604d73d..1f65c99eccf6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py index c57eb6918ec6..1c636a79d791 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py index ae313c628569..5af444e5bdf3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py index bcb6ea307276..03c5b822e84d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py index 592ccac211ba..42babb96bf63 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py index caf2b0d78d43..884b2ee5936c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py index fd9be92727e7..ad67b52134bb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py index 714b8a42a01c..0e369d7a8fe7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py @@ -69,17 +69,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py index 538d3616e5ad..164efffce1a0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py index 4be00a640f44..76de57f00eda 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index 2fbb097353c9..82b4395c9eb7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -75,17 +75,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py index 4a1cea1436c7..8c5600bc849e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index 56d8b7287877..5a1ab322ad53 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -155,17 +155,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py index 8638cd00fe8a..69f2471f34e6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py index 7b2816382d25..2ef10b0ce955 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py index b82b9f90af6c..37cf0f15d9ce 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py index f67d802c74f9..30dd8c65ccb2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py index 8467a776ad15..ee04c432f805 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py index f673ffc6f416..987f85a00356 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py index a3ba4438023c..088d551566f6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py @@ -107,17 +107,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py index cddd46e070a2..fee5fb637ddd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py index df31f576e8d0..fdd039818ecc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py index 968d03abf360..86f9c39c19fc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py index b5da7906f325..c920d603a1ef 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py index 18db6118e37c..e415d2587321 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py index 6387a99bcb83..9e0a66de7021 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py index ce4d06f08640..bcedc25d0d21 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index 56f10646cda8..2fabaf46797d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index da55a55ae9a9..eceac96e89cc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -64,17 +64,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py index a825e0674f2e..145da3a17df2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py index 8ad3b791e847..dbfc7d4c203a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py index afb355204443..4ddf3eeed826 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py index 5d694957fb29..979279ac8906 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py index 985aca80fd1b..f98afc607ccb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py index e6ada1f449a7..b76c4d8191df 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py index cfc732d9cae1..a66d96f3ad3e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py index e5a76bc2dbcf..c71c17735a33 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py @@ -61,17 +61,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py index 24b30652d657..af3eaefd8d57 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py @@ -59,17 +59,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py index e1514ebc34a6..aa8f0bb74444 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py index 8c8853839c41..1c4010db6d35 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py index 9c278d447867..60ce14ce6438 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index a61af35b7e23..db8e3b58fb47 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -66,17 +66,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py index ebba5f003946..5ef913ddc2ab 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py index 9b77e7363bb3..cd9e72871775 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py index 62714c8d3914..54cef624ef3d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py index 8893c7410ce2..8d48cf54a72d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index 498647673e14..0ad36f9d77a7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -68,17 +68,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py index 4100e19edfd0..55901b7d0b51 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py index aa76a7136dd7..a01a869a91be 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py index 84c5aea4607f..197da0420f67 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py index 1aa526d746cc..a87535a4ddea 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py index 56368f36779d..c1a3201e0736 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py index 1e2b91f0a55d..49ed612ddf5e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py index b774593ebc5e..392aba3070cd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py index 780b551e5f8e..0736526f9f66 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py index cf4e009f56d8..ea9b01c1f1f2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py index 4b5d66090bd5..7e29d932b79f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index af08b2106da7..08181025088a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -63,17 +63,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py index 6957ece5b860..8218e29bebd0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py index 17e86a00e7d5..a52ab77f9cdf 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py index 3bf11509bad1..e1115925fbb2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py index 03d05b7be8af..327ca9546556 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py index d65b57c11542..6d2f433ff86b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py index 23503db6242f..bf67b3610e90 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py @@ -66,17 +66,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py index af27ab2be1c6..bdb2731db0a6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py index 08c0614678d3..d598d5cbc9f8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index a3663250ae02..c0564570457e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 15a34aee42d4..c2644a9a75ec 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py index 200bdb807c9c..727107540b8d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py index 02fb2683e524..6280af967d79 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py @@ -54,17 +54,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py index 4d0323da7999..8a6912d2bc22 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py index 3243abe84898..3bb1ccc0c8c1 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py index ce0a36181d9c..f3f9fc8a4915 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py index b6d64b98588d..62484c169307 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py index 4d20d077a968..14c7b7ef0ace 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py index c47abd4a04bd..deefaa35093b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py index 2356cd8dd8e2..4cd64834d063 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py index e9c7c3d1fa1d..1fcaf35cedf0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py index 709f0340d8d1..970bd7582756 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py @@ -16,9 +16,9 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated +from pydantic import Field, RootModel from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field, RootModel ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py index 43dac2f68c23..a90287e17b02 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py @@ -17,9 +17,9 @@ from typing import Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig +from pydantic import Field, RootModel from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field, RootModel ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py index 2b46cb9082e0..3f190edb1cd2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py index dd845d845682..0fa78c8019e0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py index 331547535ef8..1354387153c2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py index 89662a882d07..b8b27efcac95 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py index 83ce91145b77..e7d393542f0c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py index ee8182d48596..e714cc8635f9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py index 3bb60f92db62..868d38a01d4a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py index 342ad31326eb..5a86254c53fe 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py index 2dd0d3274708..8f781a6de0ca 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py index b62765b8abe9..695375f29b97 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py index 0d01949fd3a7..7a9c7ca4fd80 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py index 420a7700bc53..73b0755c0247 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py index 8deb7604d73d..1f65c99eccf6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py index c57eb6918ec6..1c636a79d791 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py index ae313c628569..5af444e5bdf3 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py index bcb6ea307276..03c5b822e84d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py index 592ccac211ba..42babb96bf63 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py index caf2b0d78d43..884b2ee5936c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py index fd9be92727e7..ad67b52134bb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py index 714b8a42a01c..0e369d7a8fe7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py @@ -69,17 +69,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py index 538d3616e5ad..164efffce1a0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py index 4be00a640f44..76de57f00eda 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py index 2fbb097353c9..82b4395c9eb7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py @@ -75,17 +75,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py index 4a1cea1436c7..8c5600bc849e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py index 56d8b7287877..5a1ab322ad53 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py @@ -155,17 +155,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py index 8638cd00fe8a..69f2471f34e6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py index 7b2816382d25..2ef10b0ce955 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py index b82b9f90af6c..37cf0f15d9ce 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py index f67d802c74f9..30dd8c65ccb2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py index 8467a776ad15..ee04c432f805 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py index f673ffc6f416..987f85a00356 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py index a3ba4438023c..088d551566f6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py @@ -107,17 +107,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py index cddd46e070a2..fee5fb637ddd 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py index df31f576e8d0..fdd039818ecc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py index 968d03abf360..86f9c39c19fc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py index b5da7906f325..c920d603a1ef 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py index 18db6118e37c..e415d2587321 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py index 6387a99bcb83..9e0a66de7021 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py index ce4d06f08640..bcedc25d0d21 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py index 56f10646cda8..2fabaf46797d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py index da55a55ae9a9..eceac96e89cc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py @@ -64,17 +64,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py index a825e0674f2e..145da3a17df2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py index 8ad3b791e847..dbfc7d4c203a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py index afb355204443..4ddf3eeed826 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py index 5d694957fb29..979279ac8906 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py index 985aca80fd1b..f98afc607ccb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py index e6ada1f449a7..b76c4d8191df 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py index cfc732d9cae1..a66d96f3ad3e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py index e5a76bc2dbcf..c71c17735a33 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py @@ -61,17 +61,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py index 24b30652d657..af3eaefd8d57 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py @@ -59,17 +59,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py index e1514ebc34a6..aa8f0bb74444 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py index 8c8853839c41..1c4010db6d35 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py index 9c278d447867..60ce14ce6438 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py index a61af35b7e23..db8e3b58fb47 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py @@ -66,17 +66,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py index ebba5f003946..5ef913ddc2ab 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py index 9b77e7363bb3..cd9e72871775 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py index 62714c8d3914..54cef624ef3d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py index 8893c7410ce2..8d48cf54a72d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py index 498647673e14..0ad36f9d77a7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py @@ -68,17 +68,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py index 4100e19edfd0..55901b7d0b51 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py index aa76a7136dd7..a01a869a91be 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py index 84c5aea4607f..197da0420f67 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py index 1aa526d746cc..a87535a4ddea 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py index 56368f36779d..c1a3201e0736 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py index 1e2b91f0a55d..49ed612ddf5e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py index b774593ebc5e..392aba3070cd 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py index 780b551e5f8e..0736526f9f66 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py index cf4e009f56d8..ea9b01c1f1f2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py index 4b5d66090bd5..7e29d932b79f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py index af08b2106da7..08181025088a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py @@ -63,17 +63,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py index 6957ece5b860..8218e29bebd0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py index 17e86a00e7d5..a52ab77f9cdf 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py index 3bf11509bad1..e1115925fbb2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py index 03d05b7be8af..327ca9546556 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py index d65b57c11542..6d2f433ff86b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py index 23503db6242f..bf67b3610e90 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py @@ -66,17 +66,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py index af27ab2be1c6..bdb2731db0a6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py index 08c0614678d3..d598d5cbc9f8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index a3663250ae02..c0564570457e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 15a34aee42d4..c2644a9a75ec 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py index 200bdb807c9c..727107540b8d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py index 02fb2683e524..6280af967d79 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py @@ -54,17 +54,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py index 4d0323da7999..8a6912d2bc22 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py index 3243abe84898..3bb1ccc0c8c1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py index 87cc8a3f2a2a..a0c23f97e194 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py index b6d64b98588d..62484c169307 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py index 4d20d077a968..14c7b7ef0ace 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py index bb3fbbb1cd0d..e4e9f67ce8c2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py index 49d7a6451afc..560237e42e2f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py index 828889908192..b1be5f1795fa 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py index 709f0340d8d1..970bd7582756 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py @@ -16,9 +16,9 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated +from pydantic import Field, RootModel from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field, RootModel ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py index 43dac2f68c23..a90287e17b02 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py @@ -17,9 +17,9 @@ from typing import Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig +from pydantic import Field, RootModel from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field, RootModel ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py index 3d5782d0d1ca..685e8ef32495 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py index b303b82d0c34..eff51f9ef8d7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py index 39ac2a7e0f68..dec32e071db5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py index b012303f29aa..5706ec9e5731 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py index c3990bb5d7a6..da5355bb5e37 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py index f556f04de30a..fcef0bf8cc2b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py index ba921d513ea5..64e8ebe14e74 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py index 45bcc225bc64..e9d461968d1a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py index e593ba86fceb..aa5854c6cac7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py index 7430eb1787ca..8fdee39d374b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py index 7f1cc8fde97f..04b9bb3d7083 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py index 82f026964ae4..819baace619b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py index 2cb3fc470658..417a97dbbfac 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py index 0f854bacdd54..f1dac5159ec8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py index 15b76749fa90..6dde68cd207d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py index 981ef05acdd8..5b644df6804d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py index 27966281158f..e9ab161c3ee0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py index 957868b83df0..58cca49fabe2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py index cc65d8d533ab..3e4d4aaa5ab9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py index 6e8088cd9ad7..07bb95005f04 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py index 3dfe77ba0dd4..1584f5495d35 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py index 7b71819ff8c8..3143308c4adc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py index 376c00c11a6e..9dc43436d64b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py @@ -76,17 +76,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py index 733be97f744a..b6dfc5f30b56 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py index 023b2041cec0..00d61b7c2f78 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py @@ -156,17 +156,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py index ac40e2c4bc11..34492cb0275f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py index bc74f9eb3c61..220394c28a9e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py index 1eae696b956c..ea56d0a0f007 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py index cdf218a63f41..bc669becedf4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py index 5f6c1037346e..31cf861a7046 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py index 5ea4c7ab3ded..eda0ea4c7ae5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py index f3ed129507f1..92c6262a497e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py @@ -108,17 +108,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py index 9460f251a3e6..7fd62a896014 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py index 23a96af19797..a05cbfa3d192 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py index b217b64eb254..af1e83086f42 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py index fb5f216ebb44..f4d84456651c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py index 5a4a2a75237a..e883494c8405 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py index a30be459a686..86c48b413265 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py index 62563ea62df6..e6f6b7385918 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py index 7d3de9da442a..96d58fc6a5f0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py index 26d0ec8a5b52..3b11f07095bc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py @@ -65,17 +65,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py index 7a18498a600a..2013fdd4379c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py index 7b27d759a90f..b1fc52795069 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py index 92b1f8db6a4c..56ab6f77328f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py index df7da9890ada..ba9165390936 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py index a0fd00fd2afa..f81799057a8a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py index c67a3848eb33..a2ce1bbc5005 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py index 822cf2e6cd24..7bf238b8cf79 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py index d9fba557ebc0..d071207818a3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py @@ -61,17 +61,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py index 6d24c777f959..1b8ea337daea 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py @@ -60,17 +60,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py index a1885ba09446..cf70e94e6a24 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py index 632d1194dab0..9b85b2c27dca 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py index 427a8b48ea90..7defcfad2f93 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py index d2c8d15aafdf..1589dbaa7953 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py @@ -67,17 +67,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py index c6b346a9fdc9..8f3d33c2dfc1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py index 29a10ce79b22..e9c018c58bd2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py index 603a49deedd3..6073299a9342 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py index 955b78f1c6d7..49b0badafbbb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py index eaeed02c2863..06bd8c9a673c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py @@ -69,17 +69,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py index d601db0ad9a0..f92deec10b26 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py index 0a2b03923da7..e44d76888d15 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py index 2098b806eaf7..11c6c27d7aaf 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py index 301804609080..e80ed6fc7c5d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py index 707204fbcd30..12a8dacbd305 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py index f75e2bbd25b8..be88d0e42698 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py index 0cdd8845df4a..32fc185cba15 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py index 37759f82dfc5..6e5df9c925f5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py index 35e26e8b6f0c..7ac17242db87 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py index fd3b9b2c796a..950d8d45703a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py index cb3dfb6818fb..7d5f9c0a6f5c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py @@ -64,17 +64,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py index f19810c852b5..98b0b1af0c0a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py index 8066905e52e9..96d97d9f7a49 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py index b137fea8e6de..9cd8fbea443a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py index 384a74097ba9..5ca5c3e784bc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py index d65b57c11542..6d2f433ff86b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py index 20292e683cea..fb06bb71d49d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py @@ -67,17 +67,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py index b6adecb0dfdc..fb36fcfb6b3c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py index 3bb414c6404b..fcdedb28e213 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index fee88aee16f8..0c691226512c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 84e46fc2ea38..dcb2075d28e5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py index e792e29726bb..9ec0e57db5af 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py index 7474b3bb10c6..ffd82e303275 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py @@ -55,17 +55,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py index b63d689801b2..5e42d47d9c42 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py index 3243abe84898..3bb1ccc0c8c1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py index 87cc8a3f2a2a..a0c23f97e194 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py index b6d64b98588d..62484c169307 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py index 4d20d077a968..14c7b7ef0ace 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py index bb3fbbb1cd0d..e4e9f67ce8c2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py index 49d7a6451afc..560237e42e2f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py index 828889908192..b1be5f1795fa 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py index 709f0340d8d1..970bd7582756 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py @@ -16,9 +16,9 @@ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated +from pydantic import Field, RootModel from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field, RootModel ANYOFCOLOR_ANY_OF_SCHEMAS = ["List[int]", "str"] diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py index 43dac2f68c23..a90287e17b02 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py @@ -17,9 +17,9 @@ from typing import Optional from petstore_api.models.basque_pig import BasquePig from petstore_api.models.danish_pig import DanishPig +from pydantic import Field, RootModel from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self -from pydantic import Field, RootModel ANYOFPIG_ANY_OF_SCHEMAS = ["BasquePig", "DanishPig"] diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py index 3d5782d0d1ca..685e8ef32495 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index b303b82d0c34..eff51f9ef8d7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py index 39ac2a7e0f68..dec32e071db5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py index b012303f29aa..5706ec9e5731 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py index c3990bb5d7a6..da5355bb5e37 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py index f556f04de30a..fcef0bf8cc2b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py index ba921d513ea5..64e8ebe14e74 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py index 45bcc225bc64..e9d461968d1a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py index e593ba86fceb..aa5854c6cac7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/category.py b/samples/openapi3/client/petstore/python/petstore_api/models/category.py index 7430eb1787ca..8fdee39d374b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/category.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py index 7f1cc8fde97f..04b9bb3d7083 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py index 82f026964ae4..819baace619b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py index 2cb3fc470658..417a97dbbfac 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/client.py b/samples/openapi3/client/petstore/python/petstore_api/models/client.py index 0f854bacdd54..f1dac5159ec8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/client.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py index 15b76749fa90..6dde68cd207d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py index 981ef05acdd8..5b644df6804d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py index 27966281158f..e9ab161c3ee0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py index 957868b83df0..58cca49fabe2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py index cc65d8d533ab..3e4d4aaa5ab9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py index 6e8088cd9ad7..07bb95005f04 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py index 3dfe77ba0dd4..1584f5495d35 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py index 7b71819ff8c8..3143308c4adc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py index 376c00c11a6e..9dc43436d64b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py @@ -76,17 +76,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py index 733be97f744a..b6dfc5f30b56 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index 023b2041cec0..00d61b7c2f78 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -156,17 +156,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py index ac40e2c4bc11..34492cb0275f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file.py b/samples/openapi3/client/petstore/python/petstore_api/models/file.py index bc74f9eb3c61..220394c28a9e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py index 1eae696b956c..ea56d0a0f007 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py index cdf218a63f41..bc669becedf4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py index 5f6c1037346e..31cf861a7046 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py index 5ea4c7ab3ded..eda0ea4c7ae5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py index f3ed129507f1..92c6262a497e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py @@ -108,17 +108,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py index 9460f251a3e6..7fd62a896014 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py index 23a96af19797..a05cbfa3d192 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py index b217b64eb254..af1e83086f42 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/info.py b/samples/openapi3/client/petstore/python/petstore_api/models/info.py index fb5f216ebb44..f4d84456651c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/info.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py index 5a4a2a75237a..e883494c8405 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py index a30be459a686..86c48b413265 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py index 62563ea62df6..e6f6b7385918 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index 7d3de9da442a..96d58fc6a5f0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py index 26d0ec8a5b52..3b11f07095bc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py @@ -65,17 +65,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index 7a18498a600a..2013fdd4379c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py index 7b27d759a90f..b1fc52795069 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py index 92b1f8db6a4c..56ab6f77328f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py index df7da9890ada..ba9165390936 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py index a0fd00fd2afa..f81799057a8a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py index c67a3848eb33..a2ce1bbc5005 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/name.py b/samples/openapi3/client/petstore/python/petstore_api/models/name.py index 822cf2e6cd24..7bf238b8cf79 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/name.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py index d9fba557ebc0..d071207818a3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py @@ -61,17 +61,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py index 6d24c777f959..1b8ea337daea 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py @@ -60,17 +60,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py index a1885ba09446..cf70e94e6a24 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py index 632d1194dab0..9b85b2c27dca 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py index 427a8b48ea90..7defcfad2f93 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/order.py b/samples/openapi3/client/petstore/python/petstore_api/models/order.py index d2c8d15aafdf..1589dbaa7953 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -67,17 +67,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py index c6b346a9fdc9..8f3d33c2dfc1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py index 29a10ce79b22..e9c018c58bd2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py index 603a49deedd3..6073299a9342 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py index 955b78f1c6d7..49b0badafbbb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py index eaeed02c2863..06bd8c9a673c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -69,17 +69,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py index d601db0ad9a0..f92deec10b26 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py index 0a2b03923da7..e44d76888d15 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py index 2098b806eaf7..11c6c27d7aaf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py index 301804609080..e80ed6fc7c5d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py index 707204fbcd30..12a8dacbd305 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py index f75e2bbd25b8..be88d0e42698 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py index 0cdd8845df4a..32fc185cba15 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py index 37759f82dfc5..6e5df9c925f5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py index 35e26e8b6f0c..7ac17242db87 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py index fd3b9b2c796a..950d8d45703a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py index cb3dfb6818fb..7d5f9c0a6f5c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py @@ -64,17 +64,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py index f19810c852b5..98b0b1af0c0a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task.py b/samples/openapi3/client/petstore/python/petstore_api/models/task.py index 8066905e52e9..96d97d9f7a49 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py index b137fea8e6de..9cd8fbea443a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py index 384a74097ba9..5ca5c3e784bc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py index d65b57c11542..6d2f433ff86b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py index 20292e683cea..fb06bb71d49d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py @@ -67,17 +67,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py index b6adecb0dfdc..fb36fcfb6b3c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py index 3bb414c6404b..fcdedb28e213 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index fee88aee16f8..0c691226512c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 84e46fc2ea38..dcb2075d28e5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py index e792e29726bb..9ec0e57db5af 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/user.py b/samples/openapi3/client/petstore/python/petstore_api/models/user.py index 7474b3bb10c6..ffd82e303275 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/user.py @@ -55,17 +55,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py index b63d689801b2..5e42d47d9c42 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True)) - def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" return self.model_dump(by_alias=True) + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return pprint.pformat(self.to_json()) From b65102090072130abbe10b159e4d269a1404f290 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Tue, 17 Feb 2026 12:50:43 +0100 Subject: [PATCH 08/13] [FIX] Pig(RootModel... --- .../resources/python/model_anyof.mustache | 2 +- .../resources/python/model_generic.mustache | 4 +- .../resources/python/model_oneof.mustache | 2 +- .../openapi_client/models/bird.py | 4 +- .../openapi_client/models/category.py | 4 +- .../openapi_client/models/data_query.py | 4 +- .../openapi_client/models/default_value.py | 4 +- .../models/number_properties_only.py | 4 +- .../openapi_client/models/pet.py | 4 +- .../openapi_client/models/query.py | 4 +- .../openapi_client/models/tag.py | 4 +- ...st_form_object_multipart_request_marker.py | 4 +- ...ue_object_all_of_query_object_parameter.py | 4 +- ...rue_array_string_query_object_parameter.py | 4 +- .../python/openapi_client/models/bird.py | 4 +- .../python/openapi_client/models/category.py | 4 +- .../openapi_client/models/data_query.py | 4 +- .../openapi_client/models/default_value.py | 4 +- .../models/number_properties_only.py | 4 +- .../python/openapi_client/models/pet.py | 4 +- .../python/openapi_client/models/query.py | 4 +- .../python/openapi_client/models/tag.py | 4 +- ...st_form_object_multipart_request_marker.py | 4 +- ...ue_object_all_of_query_object_parameter.py | 4 +- ...rue_array_string_query_object_parameter.py | 4 +- .../models/additional_properties_any_type.py | 4 +- .../models/additional_properties_class.py | 4 +- .../models/additional_properties_object.py | 4 +- ...tional_properties_with_description_only.py | 4 +- .../petstore_api/models/all_of_super_model.py | 4 +- .../models/all_of_with_single_ref.py | 4 +- .../petstore_api/models/animal.py | 4 +- .../models/array_of_array_of_model.py | 4 +- .../models/array_of_array_of_number_only.py | 4 +- .../models/array_of_number_only.py | 4 +- .../petstore_api/models/array_test.py | 4 +- .../petstore_api/models/base_discriminator.py | 4 +- .../petstore_api/models/basque_pig.py | 4 +- .../petstore_api/models/bathing.py | 4 +- .../petstore_api/models/capitalization.py | 4 +- .../python-aiohttp/petstore_api/models/cat.py | 4 +- .../petstore_api/models/category.py | 4 +- .../models/circular_all_of_ref.py | 4 +- .../models/circular_reference_model.py | 4 +- .../petstore_api/models/class_model.py | 4 +- .../petstore_api/models/client.py | 4 +- .../petstore_api/models/creature.py | 4 +- .../petstore_api/models/creature_info.py | 4 +- .../petstore_api/models/danish_pig.py | 4 +- .../petstore_api/models/deprecated_object.py | 4 +- .../models/discriminator_all_of_sub.py | 4 +- .../models/discriminator_all_of_super.py | 4 +- .../python-aiohttp/petstore_api/models/dog.py | 4 +- .../petstore_api/models/dummy_model.py | 4 +- .../petstore_api/models/enum_arrays.py | 4 +- .../models/enum_ref_with_default_value.py | 4 +- .../petstore_api/models/enum_test.py | 4 +- .../petstore_api/models/feeding.py | 4 +- .../petstore_api/models/file.py | 4 +- .../models/file_schema_test_class.py | 4 +- .../petstore_api/models/first_ref.py | 4 +- .../python-aiohttp/petstore_api/models/foo.py | 4 +- .../models/foo_get_default_response.py | 4 +- .../petstore_api/models/format_test.py | 4 +- .../petstore_api/models/has_only_read_only.py | 4 +- .../models/health_check_result.py | 4 +- .../petstore_api/models/hunting_dog.py | 4 +- .../petstore_api/models/info.py | 4 +- .../models/inner_dict_with_property.py | 4 +- .../petstore_api/models/input_all_of.py | 4 +- .../petstore_api/models/list_class.py | 4 +- .../models/map_of_array_of_model.py | 4 +- .../petstore_api/models/map_test.py | 4 +- ...perties_and_additional_properties_class.py | 4 +- .../petstore_api/models/model200_response.py | 4 +- .../petstore_api/models/model_api_response.py | 4 +- .../petstore_api/models/model_field.py | 4 +- .../petstore_api/models/model_return.py | 4 +- .../petstore_api/models/multi_arrays.py | 4 +- .../petstore_api/models/name.py | 4 +- .../petstore_api/models/nullable_class.py | 4 +- .../petstore_api/models/nullable_property.py | 4 +- .../petstore_api/models/number_only.py | 4 +- .../object_to_test_additional_properties.py | 4 +- .../models/object_with_deprecated_fields.py | 4 +- .../petstore_api/models/order.py | 4 +- .../petstore_api/models/outer_composite.py | 4 +- .../models/outer_object_with_enum_property.py | 4 +- .../petstore_api/models/parent.py | 4 +- .../models/parent_with_optional_dict.py | 4 +- .../python-aiohttp/petstore_api/models/pet.py | 4 +- .../python-aiohttp/petstore_api/models/pig.py | 2 +- .../petstore_api/models/pony_sizes.py | 4 +- .../petstore_api/models/poop_cleaning.py | 4 +- .../petstore_api/models/primitive_string.py | 4 +- .../petstore_api/models/property_map.py | 4 +- .../models/property_name_collision.py | 4 +- .../petstore_api/models/read_only_first.py | 4 +- .../models/second_circular_all_of_ref.py | 4 +- .../petstore_api/models/second_ref.py | 4 +- .../models/self_reference_model.py | 4 +- .../petstore_api/models/special_model_name.py | 4 +- .../petstore_api/models/special_name.py | 4 +- .../python-aiohttp/petstore_api/models/tag.py | 4 +- .../petstore_api/models/task.py | 4 +- ..._error_responses_with_model400_response.py | 4 +- ..._error_responses_with_model404_response.py | 4 +- ..._freeform_additional_properties_request.py | 4 +- .../models/test_model_with_enum_default.py | 4 +- ...t_for_multipart_requests_request_marker.py | 4 +- .../petstore_api/models/tiger.py | 4 +- ...t_with_additional_model_list_properties.py | 4 +- ..._with_additional_string_list_properties.py | 4 +- ...th_additional_properties_request_object.py | 4 +- .../petstore_api/models/user.py | 4 +- .../petstore_api/models/with_nested_one_of.py | 4 +- .../models/additional_properties_any_type.py | 4 +- .../models/additional_properties_class.py | 4 +- .../models/additional_properties_object.py | 4 +- ...tional_properties_with_description_only.py | 4 +- .../petstore_api/models/all_of_super_model.py | 4 +- .../models/all_of_with_single_ref.py | 4 +- .../petstore_api/models/animal.py | 4 +- .../models/array_of_array_of_model.py | 4 +- .../models/array_of_array_of_number_only.py | 4 +- .../models/array_of_number_only.py | 4 +- .../petstore_api/models/array_test.py | 4 +- .../petstore_api/models/base_discriminator.py | 4 +- .../petstore_api/models/basque_pig.py | 4 +- .../petstore_api/models/bathing.py | 4 +- .../petstore_api/models/capitalization.py | 4 +- .../python-httpx/petstore_api/models/cat.py | 4 +- .../petstore_api/models/category.py | 4 +- .../models/circular_all_of_ref.py | 4 +- .../models/circular_reference_model.py | 4 +- .../petstore_api/models/class_model.py | 4 +- .../petstore_api/models/client.py | 4 +- .../petstore_api/models/creature.py | 4 +- .../petstore_api/models/creature_info.py | 4 +- .../petstore_api/models/danish_pig.py | 4 +- .../petstore_api/models/deprecated_object.py | 4 +- .../models/discriminator_all_of_sub.py | 4 +- .../models/discriminator_all_of_super.py | 4 +- .../python-httpx/petstore_api/models/dog.py | 4 +- .../petstore_api/models/dummy_model.py | 4 +- .../petstore_api/models/enum_arrays.py | 4 +- .../models/enum_ref_with_default_value.py | 4 +- .../petstore_api/models/enum_test.py | 4 +- .../petstore_api/models/feeding.py | 4 +- .../python-httpx/petstore_api/models/file.py | 4 +- .../models/file_schema_test_class.py | 4 +- .../petstore_api/models/first_ref.py | 4 +- .../python-httpx/petstore_api/models/foo.py | 4 +- .../models/foo_get_default_response.py | 4 +- .../petstore_api/models/format_test.py | 4 +- .../petstore_api/models/has_only_read_only.py | 4 +- .../models/health_check_result.py | 4 +- .../petstore_api/models/hunting_dog.py | 4 +- .../python-httpx/petstore_api/models/info.py | 4 +- .../models/inner_dict_with_property.py | 4 +- .../petstore_api/models/input_all_of.py | 4 +- .../petstore_api/models/list_class.py | 4 +- .../models/map_of_array_of_model.py | 4 +- .../petstore_api/models/map_test.py | 4 +- ...perties_and_additional_properties_class.py | 4 +- .../petstore_api/models/model200_response.py | 4 +- .../petstore_api/models/model_api_response.py | 4 +- .../petstore_api/models/model_field.py | 4 +- .../petstore_api/models/model_return.py | 4 +- .../petstore_api/models/multi_arrays.py | 4 +- .../python-httpx/petstore_api/models/name.py | 4 +- .../petstore_api/models/nullable_class.py | 4 +- .../petstore_api/models/nullable_property.py | 4 +- .../petstore_api/models/number_only.py | 4 +- .../object_to_test_additional_properties.py | 4 +- .../models/object_with_deprecated_fields.py | 4 +- .../python-httpx/petstore_api/models/order.py | 4 +- .../petstore_api/models/outer_composite.py | 4 +- .../models/outer_object_with_enum_property.py | 4 +- .../petstore_api/models/parent.py | 4 +- .../models/parent_with_optional_dict.py | 4 +- .../python-httpx/petstore_api/models/pet.py | 4 +- .../python-httpx/petstore_api/models/pig.py | 2 +- .../petstore_api/models/pony_sizes.py | 4 +- .../petstore_api/models/poop_cleaning.py | 4 +- .../petstore_api/models/primitive_string.py | 4 +- .../petstore_api/models/property_map.py | 4 +- .../models/property_name_collision.py | 4 +- .../petstore_api/models/read_only_first.py | 4 +- .../models/second_circular_all_of_ref.py | 4 +- .../petstore_api/models/second_ref.py | 4 +- .../models/self_reference_model.py | 4 +- .../petstore_api/models/special_model_name.py | 4 +- .../petstore_api/models/special_name.py | 4 +- .../python-httpx/petstore_api/models/tag.py | 4 +- .../python-httpx/petstore_api/models/task.py | 4 +- ..._error_responses_with_model400_response.py | 4 +- ..._error_responses_with_model404_response.py | 4 +- ..._freeform_additional_properties_request.py | 4 +- .../models/test_model_with_enum_default.py | 4 +- ...t_for_multipart_requests_request_marker.py | 4 +- .../python-httpx/petstore_api/models/tiger.py | 4 +- ...t_with_additional_model_list_properties.py | 4 +- ..._with_additional_string_list_properties.py | 4 +- ...th_additional_properties_request_object.py | 4 +- .../python-httpx/petstore_api/models/user.py | 4 +- .../petstore_api/models/with_nested_one_of.py | 4 +- .../models/additional_properties_any_type.py | 4 +- .../models/additional_properties_class.py | 4 +- .../models/additional_properties_object.py | 4 +- ...tional_properties_with_description_only.py | 4 +- .../petstore_api/models/all_of_super_model.py | 4 +- .../models/all_of_with_single_ref.py | 4 +- .../petstore_api/models/animal.py | 4 +- .../models/array_of_array_of_model.py | 4 +- .../models/array_of_array_of_number_only.py | 4 +- .../models/array_of_number_only.py | 4 +- .../petstore_api/models/array_test.py | 4 +- .../petstore_api/models/base_discriminator.py | 4 +- .../petstore_api/models/basque_pig.py | 4 +- .../petstore_api/models/bathing.py | 4 +- .../petstore_api/models/capitalization.py | 4 +- .../petstore_api/models/cat.py | 4 +- .../petstore_api/models/category.py | 4 +- .../models/circular_all_of_ref.py | 4 +- .../models/circular_reference_model.py | 4 +- .../petstore_api/models/class_model.py | 4 +- .../petstore_api/models/client.py | 4 +- .../petstore_api/models/creature.py | 4 +- .../petstore_api/models/creature_info.py | 4 +- .../petstore_api/models/danish_pig.py | 4 +- .../petstore_api/models/deprecated_object.py | 4 +- .../models/discriminator_all_of_sub.py | 4 +- .../models/discriminator_all_of_super.py | 4 +- .../petstore_api/models/dog.py | 4 +- .../petstore_api/models/dummy_model.py | 4 +- .../petstore_api/models/enum_arrays.py | 4 +- .../models/enum_ref_with_default_value.py | 4 +- .../petstore_api/models/enum_test.py | 4 +- .../petstore_api/models/feeding.py | 4 +- .../petstore_api/models/file.py | 4 +- .../models/file_schema_test_class.py | 4 +- .../petstore_api/models/first_ref.py | 4 +- .../petstore_api/models/foo.py | 4 +- .../models/foo_get_default_response.py | 4 +- .../petstore_api/models/format_test.py | 4 +- .../petstore_api/models/has_only_read_only.py | 4 +- .../models/health_check_result.py | 4 +- .../petstore_api/models/hunting_dog.py | 4 +- .../petstore_api/models/info.py | 4 +- .../models/inner_dict_with_property.py | 4 +- .../petstore_api/models/input_all_of.py | 4 +- .../petstore_api/models/list_class.py | 4 +- .../models/map_of_array_of_model.py | 4 +- .../petstore_api/models/map_test.py | 4 +- ...perties_and_additional_properties_class.py | 4 +- .../petstore_api/models/model200_response.py | 4 +- .../petstore_api/models/model_api_response.py | 4 +- .../petstore_api/models/model_field.py | 4 +- .../petstore_api/models/model_return.py | 4 +- .../petstore_api/models/multi_arrays.py | 4 +- .../petstore_api/models/name.py | 4 +- .../petstore_api/models/nullable_class.py | 4 +- .../petstore_api/models/nullable_property.py | 4 +- .../petstore_api/models/number_only.py | 4 +- .../object_to_test_additional_properties.py | 4 +- .../models/object_with_deprecated_fields.py | 4 +- .../petstore_api/models/order.py | 4 +- .../petstore_api/models/outer_composite.py | 4 +- .../models/outer_object_with_enum_property.py | 4 +- .../petstore_api/models/parent.py | 4 +- .../models/parent_with_optional_dict.py | 4 +- .../petstore_api/models/pet.py | 4 +- .../petstore_api/models/pig.py | 2 +- .../petstore_api/models/pony_sizes.py | 4 +- .../petstore_api/models/poop_cleaning.py | 4 +- .../petstore_api/models/primitive_string.py | 4 +- .../petstore_api/models/property_map.py | 4 +- .../models/property_name_collision.py | 4 +- .../petstore_api/models/read_only_first.py | 4 +- .../models/second_circular_all_of_ref.py | 4 +- .../petstore_api/models/second_ref.py | 4 +- .../models/self_reference_model.py | 4 +- .../petstore_api/models/special_model_name.py | 4 +- .../petstore_api/models/special_name.py | 4 +- .../petstore_api/models/tag.py | 4 +- .../petstore_api/models/task.py | 4 +- ..._error_responses_with_model400_response.py | 4 +- ..._error_responses_with_model404_response.py | 4 +- ..._freeform_additional_properties_request.py | 4 +- .../models/test_model_with_enum_default.py | 4 +- ...t_for_multipart_requests_request_marker.py | 4 +- .../petstore_api/models/tiger.py | 4 +- ...t_with_additional_model_list_properties.py | 4 +- ..._with_additional_string_list_properties.py | 4 +- ...th_additional_properties_request_object.py | 4 +- .../petstore_api/models/user.py | 4 +- .../petstore_api/models/with_nested_one_of.py | 4 +- .../models/additional_properties_any_type.py | 4 +- .../models/additional_properties_class.py | 4 +- .../models/additional_properties_object.py | 4 +- ...tional_properties_with_description_only.py | 4 +- .../petstore_api/models/all_of_super_model.py | 4 +- .../models/all_of_with_single_ref.py | 4 +- .../python/petstore_api/models/animal.py | 4 +- .../models/array_of_array_of_model.py | 4 +- .../models/array_of_array_of_number_only.py | 4 +- .../models/array_of_number_only.py | 4 +- .../python/petstore_api/models/array_test.py | 4 +- .../petstore_api/models/base_discriminator.py | 4 +- .../python/petstore_api/models/basque_pig.py | 4 +- .../python/petstore_api/models/bathing.py | 4 +- .../petstore_api/models/capitalization.py | 4 +- .../python/petstore_api/models/cat.py | 4 +- .../python/petstore_api/models/category.py | 4 +- .../models/circular_all_of_ref.py | 4 +- .../models/circular_reference_model.py | 4 +- .../python/petstore_api/models/class_model.py | 4 +- .../python/petstore_api/models/client.py | 4 +- .../python/petstore_api/models/creature.py | 4 +- .../petstore_api/models/creature_info.py | 4 +- .../python/petstore_api/models/danish_pig.py | 4 +- .../petstore_api/models/deprecated_object.py | 4 +- .../models/discriminator_all_of_sub.py | 4 +- .../models/discriminator_all_of_super.py | 4 +- .../python/petstore_api/models/dog.py | 4 +- .../python/petstore_api/models/dummy_model.py | 4 +- .../python/petstore_api/models/enum_arrays.py | 4 +- .../models/enum_ref_with_default_value.py | 4 +- .../python/petstore_api/models/enum_test.py | 4 +- .../python/petstore_api/models/feeding.py | 4 +- .../python/petstore_api/models/file.py | 4 +- .../models/file_schema_test_class.py | 4 +- .../python/petstore_api/models/first_ref.py | 4 +- .../python/petstore_api/models/foo.py | 4 +- .../models/foo_get_default_response.py | 4 +- .../python/petstore_api/models/format_test.py | 4 +- .../petstore_api/models/has_only_read_only.py | 4 +- .../models/health_check_result.py | 4 +- .../python/petstore_api/models/hunting_dog.py | 4 +- .../python/petstore_api/models/info.py | 4 +- .../models/inner_dict_with_property.py | 4 +- .../petstore_api/models/input_all_of.py | 4 +- .../python/petstore_api/models/list_class.py | 4 +- .../models/map_of_array_of_model.py | 4 +- .../python/petstore_api/models/map_test.py | 4 +- ...perties_and_additional_properties_class.py | 4 +- .../petstore_api/models/model200_response.py | 4 +- .../petstore_api/models/model_api_response.py | 4 +- .../python/petstore_api/models/model_field.py | 4 +- .../petstore_api/models/model_return.py | 4 +- .../petstore_api/models/multi_arrays.py | 4 +- .../python/petstore_api/models/name.py | 4 +- .../petstore_api/models/nullable_class.py | 4 +- .../petstore_api/models/nullable_property.py | 4 +- .../python/petstore_api/models/number_only.py | 4 +- .../object_to_test_additional_properties.py | 4 +- .../models/object_with_deprecated_fields.py | 4 +- .../python/petstore_api/models/order.py | 4 +- .../petstore_api/models/outer_composite.py | 4 +- .../models/outer_object_with_enum_property.py | 4 +- .../python/petstore_api/models/parent.py | 4 +- .../models/parent_with_optional_dict.py | 4 +- .../python/petstore_api/models/pet.py | 4 +- .../python/petstore_api/models/pig.py | 2 +- .../python/petstore_api/models/pony_sizes.py | 4 +- .../petstore_api/models/poop_cleaning.py | 4 +- .../petstore_api/models/primitive_string.py | 4 +- .../petstore_api/models/property_map.py | 4 +- .../models/property_name_collision.py | 4 +- .../petstore_api/models/read_only_first.py | 4 +- .../models/second_circular_all_of_ref.py | 4 +- .../python/petstore_api/models/second_ref.py | 4 +- .../models/self_reference_model.py | 4 +- .../petstore_api/models/special_model_name.py | 4 +- .../petstore_api/models/special_name.py | 4 +- .../python/petstore_api/models/tag.py | 4 +- .../python/petstore_api/models/task.py | 4 +- ..._error_responses_with_model400_response.py | 4 +- ..._error_responses_with_model404_response.py | 4 +- ..._freeform_additional_properties_request.py | 4 +- .../models/test_model_with_enum_default.py | 4 +- ...t_for_multipart_requests_request_marker.py | 4 +- .../python/petstore_api/models/tiger.py | 4 +- ...t_with_additional_model_list_properties.py | 4 +- ..._with_additional_string_list_properties.py | 4 +- ...th_additional_properties_request_object.py | 4 +- .../python/petstore_api/models/user.py | 4 +- .../petstore_api/models/with_nested_one_of.py | 4 +- .../openapi3/client/petstore/python/uv.lock | 281 ++++++++++++++++++ 390 files changed, 1053 insertions(+), 772 deletions(-) create mode 100644 samples/openapi3/client/petstore/python/uv.lock diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index 703a7e007e1d..2593a9ac378b 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -17,7 +17,7 @@ class {{classname}}(RootModel[Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyO {{{description}}}{{^description}}{{{classname}}}{{/description}} """ root: Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyOf}}{{#isNullable}}, None{{/isNullable}}] = Field( - {{#isNullable}}None{{/isNullable}}{{^isNullable}}...{{/isNullable}}{{#discriminator}}, discriminator="{{discriminatorName}}"{{/discriminator}} + {{#isNullable}}None{{/isNullable}}{{^isNullable}}...{{/isNullable}}{{#discriminator}}{{/discriminator}} ) def __getattr__(self, name): diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index 695dc754c333..72c10fba004c 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -168,11 +168,11 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache index a20411ede0d9..ab97fda35dea 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -17,7 +17,7 @@ class {{classname}}(RootModel[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/on {{{description}}}{{^description}}{{{classname}}}{{/description}} """ root: Union[{{#oneOf}}{{.}}{{^-last}}, {{/-last}}{{/oneOf}}{{#isNullable}}, None{{/isNullable}}] = Field( - {{#isNullable}}None{{/isNullable}}{{^isNullable}}...{{/isNullable}}{{#discriminator}}, discriminator="{{discriminatorName}}"{{/discriminator}} + {{#isNullable}}None{{/isNullable}}{{^isNullable}}...{{/isNullable}}{{#discriminator}}{{/discriminator}} ) def __getattr__(self, name): diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py index e461503b2a43..ab504ea13788 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py index 3a9048ae8ee4..b5d1feff8954 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py index 528ef0aedba1..469701d7adc1 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py index 91a72d879190..3afdd3cf4086 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py @@ -72,11 +72,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py index f7431648d842..54924629f13c 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py index 1cb31fc6ee44..d1447ef248bf 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py @@ -70,11 +70,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py index bd5b78711bc7..a9db31353813 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py @@ -65,11 +65,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py index fdaa35e73a13..ec088768dc6e 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py index 07ba24f8b1e6..6fc587105874 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index dca62df92f94..52a77611a10f 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 660e468d97f8..688824243b4e 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/bird.py b/samples/client/echo_api/python/openapi_client/models/bird.py index e461503b2a43..ab504ea13788 100644 --- a/samples/client/echo_api/python/openapi_client/models/bird.py +++ b/samples/client/echo_api/python/openapi_client/models/bird.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/category.py b/samples/client/echo_api/python/openapi_client/models/category.py index 3a9048ae8ee4..b5d1feff8954 100644 --- a/samples/client/echo_api/python/openapi_client/models/category.py +++ b/samples/client/echo_api/python/openapi_client/models/category.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/data_query.py b/samples/client/echo_api/python/openapi_client/models/data_query.py index 528ef0aedba1..469701d7adc1 100644 --- a/samples/client/echo_api/python/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python/openapi_client/models/data_query.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/default_value.py b/samples/client/echo_api/python/openapi_client/models/default_value.py index 91a72d879190..3afdd3cf4086 100644 --- a/samples/client/echo_api/python/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python/openapi_client/models/default_value.py @@ -72,11 +72,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py index f7431648d842..54924629f13c 100644 --- a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/pet.py b/samples/client/echo_api/python/openapi_client/models/pet.py index 1cb31fc6ee44..d1447ef248bf 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -70,11 +70,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/query.py b/samples/client/echo_api/python/openapi_client/models/query.py index bd5b78711bc7..a9db31353813 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -65,11 +65,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/tag.py b/samples/client/echo_api/python/openapi_client/models/tag.py index fdaa35e73a13..ec088768dc6e 100644 --- a/samples/client/echo_api/python/openapi_client/models/tag.py +++ b/samples/client/echo_api/python/openapi_client/models/tag.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py index 07ba24f8b1e6..6fc587105874 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index dca62df92f94..52a77611a10f 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 660e468d97f8..688824243b4e 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py index 3bb1ccc0c8c1..bc200fb99195 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py index f3f9fc8a4915..b07374ffccd7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py index 62484c169307..94c9c90a088b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py index 14c7b7ef0ace..1f589af3b288 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py index deefaa35093b..0b30cd2e8be0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py index 4cd64834d063..71025d084c28 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py index 1fcaf35cedf0..fe4451ba83d3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py index 3f190edb1cd2..6fa4d4a454b0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py index 0fa78c8019e0..028601c27645 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py index 1354387153c2..bae55244e51b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py index b8b27efcac95..8488d796deeb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py index e7d393542f0c..25e061a0493c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py @@ -72,11 +72,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py index e714cc8635f9..80fbbc69f0ba 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py index 868d38a01d4a..ea5d5fed0fad 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py index 5a86254c53fe..d28295ae3750 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py index 8f781a6de0ca..bd1f68423276 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py index 695375f29b97..4509cf9404d8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py index 7a9c7ca4fd80..6cf2bba58527 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py index 73b0755c0247..388aeb6934cb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py index 1f65c99eccf6..621e72a9bcba 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py index 1c636a79d791..384583d040ea 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py index 5af444e5bdf3..213596b2ac25 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py index 03c5b822e84d..2ab71554ced0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py index 42babb96bf63..f2c4f78ed091 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py index 884b2ee5936c..4f0467c1c95a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py index ad67b52134bb..0844ee6a4927 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py index 0e369d7a8fe7..36aea7a9805f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py @@ -71,11 +71,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py index 164efffce1a0..3f54b5b2768a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py index 76de57f00eda..1e4a8d9a6a08 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index 82b4395c9eb7..2ab5d04d5471 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -77,11 +77,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py index 8c5600bc849e..781f8b14d449 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index 5a1ab322ad53..3cb0baf0f32f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -157,11 +157,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py index 69f2471f34e6..47265928799b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py index 2ef10b0ce955..02bef49b7f62 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py index 37cf0f15d9ce..c940688cf137 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py index 30dd8c65ccb2..cf3dd91f5b20 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py index ee04c432f805..7c3d514c1475 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py index 987f85a00356..cc8fb33b1baf 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py index 088d551566f6..cacfdaab97eb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py @@ -109,11 +109,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py index fee5fb637ddd..6066f46682c6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py index fdd039818ecc..6f829c83f0ad 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py index 86f9c39c19fc..cd2436271ec9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py index c920d603a1ef..1af076053369 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py index e415d2587321..ea4cde3995b8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py index 9e0a66de7021..44abab5b841d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py index bcedc25d0d21..a6f8bfcd619b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index 2fabaf46797d..2fd3f9b22d21 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index eceac96e89cc..148b4b11e2a3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -66,11 +66,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py index 145da3a17df2..10295e10dbb4 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py index dbfc7d4c203a..7f5963510c12 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py index 4ddf3eeed826..7783a8200a82 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py index 979279ac8906..eabf59f93c8d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py index f98afc607ccb..a79d088d17da 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py index b76c4d8191df..db9b94cd8582 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py index a66d96f3ad3e..9af8ee448a6a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py index c71c17735a33..78404ee41ec6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py @@ -63,11 +63,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py index af3eaefd8d57..8f0e6a41984f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py @@ -61,11 +61,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py index aa8f0bb74444..b6c02228c5e2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py index 1c4010db6d35..79c42917a8b8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py index 60ce14ce6438..da291134461c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index db8e3b58fb47..7a3b7c57c7e7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -68,11 +68,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py index 5ef913ddc2ab..f3adc7c3b8de 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py index cd9e72871775..624e3331542e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py index 54cef624ef3d..24a1886628ce 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py index 8d48cf54a72d..256b0df2a1dc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index 0ad36f9d77a7..ea13c5465e3b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -70,11 +70,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py index 309874d6481b..4cc32f18c42d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py @@ -29,7 +29,7 @@ class Pig(RootModel[Union[BasquePig, DanishPig]]): Pig """ root: Union[BasquePig, DanishPig] = Field( - ..., discriminator="class_name" + ... ) def __getattr__(self, name): diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py index 55901b7d0b51..b7bc4533ca78 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py index a01a869a91be..8e6803afdcbb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py index 197da0420f67..809a7741366c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py index a87535a4ddea..336223a9c4df 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py index c1a3201e0736..4ac90edf7de2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py index 49ed612ddf5e..e629b9f1a094 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py index 392aba3070cd..d2551e5802ac 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py index 0736526f9f66..2507e2b84d4a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py index ea9b01c1f1f2..286894e0d559 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py index 7e29d932b79f..13d5b24c52e0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index 08181025088a..c54f89dfc489 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -65,11 +65,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py index 8218e29bebd0..f14a2afd272f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py index a52ab77f9cdf..158c3b99686b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py index e1115925fbb2..4f377a4a4d36 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py index 327ca9546556..313c499def30 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py index 6d2f433ff86b..d67bb5ef1f35 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py index bf67b3610e90..6e09516062ae 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py @@ -68,11 +68,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py index bdb2731db0a6..2bb14ff8d58e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py index d598d5cbc9f8..153a9f22de54 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index c0564570457e..9ca067dbfe25 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index c2644a9a75ec..72e05f458f96 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py index 727107540b8d..5bd3022c1efe 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py index 6280af967d79..2868cbf027c6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py @@ -56,11 +56,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py index 8a6912d2bc22..4aba1b28f89e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py index 3bb1ccc0c8c1..bc200fb99195 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py index f3f9fc8a4915..b07374ffccd7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py index 62484c169307..94c9c90a088b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py index 14c7b7ef0ace..1f589af3b288 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py index deefaa35093b..0b30cd2e8be0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py index 4cd64834d063..71025d084c28 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py index 1fcaf35cedf0..fe4451ba83d3 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py index 3f190edb1cd2..6fa4d4a454b0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py index 0fa78c8019e0..028601c27645 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py index 1354387153c2..bae55244e51b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py index b8b27efcac95..8488d796deeb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py index e7d393542f0c..25e061a0493c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py @@ -72,11 +72,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py index e714cc8635f9..80fbbc69f0ba 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py index 868d38a01d4a..ea5d5fed0fad 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py index 5a86254c53fe..d28295ae3750 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py index 8f781a6de0ca..bd1f68423276 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py index 695375f29b97..4509cf9404d8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py index 7a9c7ca4fd80..6cf2bba58527 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py index 73b0755c0247..388aeb6934cb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py index 1f65c99eccf6..621e72a9bcba 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py index 1c636a79d791..384583d040ea 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py index 5af444e5bdf3..213596b2ac25 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py index 03c5b822e84d..2ab71554ced0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py index 42babb96bf63..f2c4f78ed091 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py index 884b2ee5936c..4f0467c1c95a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py index ad67b52134bb..0844ee6a4927 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py index 0e369d7a8fe7..36aea7a9805f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py @@ -71,11 +71,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py index 164efffce1a0..3f54b5b2768a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py index 76de57f00eda..1e4a8d9a6a08 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py index 82b4395c9eb7..2ab5d04d5471 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py @@ -77,11 +77,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py index 8c5600bc849e..781f8b14d449 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py index 5a1ab322ad53..3cb0baf0f32f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py @@ -157,11 +157,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py index 69f2471f34e6..47265928799b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py index 2ef10b0ce955..02bef49b7f62 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py index 37cf0f15d9ce..c940688cf137 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py index 30dd8c65ccb2..cf3dd91f5b20 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py index ee04c432f805..7c3d514c1475 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py index 987f85a00356..cc8fb33b1baf 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py index 088d551566f6..cacfdaab97eb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py @@ -109,11 +109,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py index fee5fb637ddd..6066f46682c6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py index fdd039818ecc..6f829c83f0ad 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py index 86f9c39c19fc..cd2436271ec9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py index c920d603a1ef..1af076053369 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py index e415d2587321..ea4cde3995b8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py index 9e0a66de7021..44abab5b841d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py index bcedc25d0d21..a6f8bfcd619b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py index 2fabaf46797d..2fd3f9b22d21 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py index eceac96e89cc..148b4b11e2a3 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py @@ -66,11 +66,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py index 145da3a17df2..10295e10dbb4 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py index dbfc7d4c203a..7f5963510c12 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py index 4ddf3eeed826..7783a8200a82 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py index 979279ac8906..eabf59f93c8d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py index f98afc607ccb..a79d088d17da 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py index b76c4d8191df..db9b94cd8582 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py index a66d96f3ad3e..9af8ee448a6a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py index c71c17735a33..78404ee41ec6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py @@ -63,11 +63,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py index af3eaefd8d57..8f0e6a41984f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py @@ -61,11 +61,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py index aa8f0bb74444..b6c02228c5e2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py index 1c4010db6d35..79c42917a8b8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py index 60ce14ce6438..da291134461c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py index db8e3b58fb47..7a3b7c57c7e7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py @@ -68,11 +68,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py index 5ef913ddc2ab..f3adc7c3b8de 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py index cd9e72871775..624e3331542e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py index 54cef624ef3d..24a1886628ce 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py index 8d48cf54a72d..256b0df2a1dc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py index 0ad36f9d77a7..ea13c5465e3b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py @@ -70,11 +70,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py index 309874d6481b..4cc32f18c42d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py @@ -29,7 +29,7 @@ class Pig(RootModel[Union[BasquePig, DanishPig]]): Pig """ root: Union[BasquePig, DanishPig] = Field( - ..., discriminator="class_name" + ... ) def __getattr__(self, name): diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py index 55901b7d0b51..b7bc4533ca78 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py index a01a869a91be..8e6803afdcbb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py index 197da0420f67..809a7741366c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py index a87535a4ddea..336223a9c4df 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py index c1a3201e0736..4ac90edf7de2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py index 49ed612ddf5e..e629b9f1a094 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py index 392aba3070cd..d2551e5802ac 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py index 0736526f9f66..2507e2b84d4a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py index ea9b01c1f1f2..286894e0d559 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py index 7e29d932b79f..13d5b24c52e0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py index 08181025088a..c54f89dfc489 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py @@ -65,11 +65,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py index 8218e29bebd0..f14a2afd272f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py index a52ab77f9cdf..158c3b99686b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py index e1115925fbb2..4f377a4a4d36 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py index 327ca9546556..313c499def30 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py index 6d2f433ff86b..d67bb5ef1f35 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py index bf67b3610e90..6e09516062ae 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py @@ -68,11 +68,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py index bdb2731db0a6..2bb14ff8d58e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py index d598d5cbc9f8..153a9f22de54 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index c0564570457e..9ca067dbfe25 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index c2644a9a75ec..72e05f458f96 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py index 727107540b8d..5bd3022c1efe 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -49,11 +49,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py index 6280af967d79..2868cbf027c6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py @@ -56,11 +56,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py index 8a6912d2bc22..4aba1b28f89e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py index 3bb1ccc0c8c1..bc200fb99195 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py index a0c23f97e194..41db98c3e62f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py index 62484c169307..94c9c90a088b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py index 14c7b7ef0ace..1f589af3b288 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py index e4e9f67ce8c2..401413233f21 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py index 560237e42e2f..5dfadd977245 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py index b1be5f1795fa..28b17142a816 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py index 685e8ef32495..9505ce0b6c35 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py index eff51f9ef8d7..7776dfd14a7a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py index dec32e071db5..c6d99aec508e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py index 5706ec9e5731..9a52407bb57e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py @@ -55,11 +55,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py index da5355bb5e37..6770a2e587a4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py index fcef0bf8cc2b..3166836059f5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py index 64e8ebe14e74..c0288ed8f985 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py index e9d461968d1a..6865ed963c9a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py @@ -55,11 +55,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py index aa5854c6cac7..8c81c11b1b29 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py index 8fdee39d374b..614f25486a89 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py index 04b9bb3d7083..e1bcb36e7e68 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py index 819baace619b..616bd5a7dd49 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py index 417a97dbbfac..264a218d6dd8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py index f1dac5159ec8..aa893e0d6104 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py index 6dde68cd207d..a2698a0a3164 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py index 5b644df6804d..8b607b1d2065 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py index e9ab161c3ee0..afd589a99cfc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py index 58cca49fabe2..1717b330ec9e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py index 3e4d4aaa5ab9..b2bf6bef8628 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py index 07bb95005f04..f9839d6f278f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py @@ -72,11 +72,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py index 1584f5495d35..496d3f95f3ba 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py index 3143308c4adc..b99f6a904ce7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py index 9dc43436d64b..e56c6b336ea0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py @@ -78,11 +78,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py index b6dfc5f30b56..2ad94c2c5de1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py index 00d61b7c2f78..b508224d8b85 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py @@ -158,11 +158,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py index 34492cb0275f..ca42b4335639 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py index 220394c28a9e..554374cfbe07 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py index ea56d0a0f007..d74d8dbae883 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py index bc669becedf4..fdf46e6260a9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py index 31cf861a7046..e77a2905c9f4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py index eda0ea4c7ae5..b0db656eacfa 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py index 92c6262a497e..759262062e78 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py @@ -110,11 +110,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py index 7fd62a896014..c92fae193e56 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py index a05cbfa3d192..d062a5dfe853 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py index af1e83086f42..5e743ec84873 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py index f4d84456651c..2771d60c2318 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py index e883494c8405..9dcc377719e8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py index 86c48b413265..60c833c81dcb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py index e6f6b7385918..c0c5fc4dae85 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py index 96d58fc6a5f0..5e7a0bbfff9a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py index 3b11f07095bc..5b46fae4b015 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py @@ -67,11 +67,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py index 2013fdd4379c..e7a6eb1c4604 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -55,11 +55,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py index b1fc52795069..ae0d0de0a380 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py index 56ab6f77328f..f27857d233e2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py index ba9165390936..672d5a2c1bab 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py index f81799057a8a..affff9bc82a2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py index a2ce1bbc5005..f4429792f542 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py index 7bf238b8cf79..7392bcd94a96 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py index d071207818a3..836632f92186 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py @@ -63,11 +63,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py index 1b8ea337daea..a2100a9d605c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py @@ -62,11 +62,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py index cf70e94e6a24..8015d2627315 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py index 9b85b2c27dca..a0b501f4510e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py index 7defcfad2f93..607178e61b3e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py index 1589dbaa7953..bb5cf7cebd8b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py @@ -69,11 +69,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py index 8f3d33c2dfc1..f3c5a1d1a290 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py index e9c018c58bd2..98d966c63f88 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py index 6073299a9342..67019aee1760 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py index 49b0badafbbb..595d04b48cac 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py index 06bd8c9a673c..d10aa6bea0b3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py @@ -71,11 +71,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py index 309874d6481b..4cc32f18c42d 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py @@ -29,7 +29,7 @@ class Pig(RootModel[Union[BasquePig, DanishPig]]): Pig """ root: Union[BasquePig, DanishPig] = Field( - ..., discriminator="class_name" + ... ) def __getattr__(self, name): diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py index f92deec10b26..8330edb586e5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py index e44d76888d15..6404380de0bf 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py index 11c6c27d7aaf..1dd55054ae68 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py index e80ed6fc7c5d..ff945938c081 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py index 12a8dacbd305..17e3f07aeca9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py index be88d0e42698..696299173423 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py index 32fc185cba15..7c460b2215df 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py index 6e5df9c925f5..d034d43bf66f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py index 7ac17242db87..bf9197fce99f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py index 950d8d45703a..e75daa66036b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py index 7d5f9c0a6f5c..cb154e1ce529 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py @@ -66,11 +66,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py index 98b0b1af0c0a..e5c4b57a1731 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py index 96d97d9f7a49..68ad30765acc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py index 9cd8fbea443a..4039342bc999 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py index 5ca5c3e784bc..93d9932f5b99 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py index 6d2f433ff86b..d67bb5ef1f35 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py index fb06bb71d49d..36ecd8a5abbb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py @@ -69,11 +69,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py index fb36fcfb6b3c..427a35ab86d8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py index fcdedb28e213..897f0f0b897f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 0c691226512c..5f8e42159a24 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index dcb2075d28e5..c4e874f931ca 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py index 9ec0e57db5af..fefa4c26d8f9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py index ffd82e303275..a65ce66ddb99 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py @@ -57,11 +57,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py index 5e42d47d9c42..d1d79b8f0b04 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py index 3bb1ccc0c8c1..bc200fb99195 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py index a0c23f97e194..41db98c3e62f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py index 62484c169307..94c9c90a088b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py index 14c7b7ef0ace..1f589af3b288 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py index e4e9f67ce8c2..401413233f21 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py index 560237e42e2f..5dfadd977245 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py index b1be5f1795fa..28b17142a816 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py index 685e8ef32495..9505ce0b6c35 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index eff51f9ef8d7..7776dfd14a7a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py index dec32e071db5..c6d99aec508e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py index 5706ec9e5731..9a52407bb57e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py @@ -55,11 +55,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py index da5355bb5e37..6770a2e587a4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py @@ -73,11 +73,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py index fcef0bf8cc2b..3166836059f5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py index 64e8ebe14e74..c0288ed8f985 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py index e9d461968d1a..6865ed963c9a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py @@ -55,11 +55,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py index aa5854c6cac7..8c81c11b1b29 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/category.py b/samples/openapi3/client/petstore/python/petstore_api/models/category.py index 8fdee39d374b..614f25486a89 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/category.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py index 04b9bb3d7083..e1bcb36e7e68 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py index 819baace619b..616bd5a7dd49 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py index 417a97dbbfac..264a218d6dd8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/client.py b/samples/openapi3/client/petstore/python/petstore_api/models/client.py index f1dac5159ec8..aa893e0d6104 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/client.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py index 6dde68cd207d..a2698a0a3164 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py index 5b644df6804d..8b607b1d2065 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py index e9ab161c3ee0..afd589a99cfc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py index 58cca49fabe2..1717b330ec9e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py index 3e4d4aaa5ab9..b2bf6bef8628 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py index 07bb95005f04..f9839d6f278f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py @@ -72,11 +72,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py index 1584f5495d35..496d3f95f3ba 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py index 3143308c4adc..b99f6a904ce7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py index 9dc43436d64b..e56c6b336ea0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py @@ -78,11 +78,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py index b6dfc5f30b56..2ad94c2c5de1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index 00d61b7c2f78..b508224d8b85 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -158,11 +158,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py index 34492cb0275f..ca42b4335639 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file.py b/samples/openapi3/client/petstore/python/petstore_api/models/file.py index 220394c28a9e..554374cfbe07 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py index ea56d0a0f007..d74d8dbae883 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py index bc669becedf4..fdf46e6260a9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py index 31cf861a7046..e77a2905c9f4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py index eda0ea4c7ae5..b0db656eacfa 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py index 92c6262a497e..759262062e78 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py @@ -110,11 +110,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py index 7fd62a896014..c92fae193e56 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py index a05cbfa3d192..d062a5dfe853 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py index af1e83086f42..5e743ec84873 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/info.py b/samples/openapi3/client/petstore/python/petstore_api/models/info.py index f4d84456651c..2771d60c2318 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/info.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py index e883494c8405..9dcc377719e8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py index 86c48b413265..60c833c81dcb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py index e6f6b7385918..c0c5fc4dae85 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index 96d58fc6a5f0..5e7a0bbfff9a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py index 3b11f07095bc..5b46fae4b015 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py @@ -67,11 +67,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index 2013fdd4379c..e7a6eb1c4604 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -55,11 +55,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py index b1fc52795069..ae0d0de0a380 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py index 56ab6f77328f..f27857d233e2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py index ba9165390936..672d5a2c1bab 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py index f81799057a8a..affff9bc82a2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py index a2ce1bbc5005..f4429792f542 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/name.py b/samples/openapi3/client/petstore/python/petstore_api/models/name.py index 7bf238b8cf79..7392bcd94a96 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/name.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py index d071207818a3..836632f92186 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py @@ -63,11 +63,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py index 1b8ea337daea..a2100a9d605c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py @@ -62,11 +62,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py index cf70e94e6a24..8015d2627315 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py index 9b85b2c27dca..a0b501f4510e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py index 7defcfad2f93..607178e61b3e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/order.py b/samples/openapi3/client/petstore/python/petstore_api/models/order.py index 1589dbaa7953..bb5cf7cebd8b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -69,11 +69,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py index 8f3d33c2dfc1..f3c5a1d1a290 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py index e9c018c58bd2..98d966c63f88 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py index 6073299a9342..67019aee1760 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py index 49b0badafbbb..595d04b48cac 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py index 06bd8c9a673c..d10aa6bea0b3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -71,11 +71,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py index 309874d6481b..4cc32f18c42d 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -29,7 +29,7 @@ class Pig(RootModel[Union[BasquePig, DanishPig]]): Pig """ root: Union[BasquePig, DanishPig] = Field( - ..., discriminator="class_name" + ... ) def __getattr__(self, name): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py index f92deec10b26..8330edb586e5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py index e44d76888d15..6404380de0bf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py @@ -74,11 +74,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py index 11c6c27d7aaf..1dd55054ae68 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py index e80ed6fc7c5d..ff945938c081 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py index 12a8dacbd305..17e3f07aeca9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py @@ -52,11 +52,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py index be88d0e42698..696299173423 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py index 32fc185cba15..7c460b2215df 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py index 6e5df9c925f5..d034d43bf66f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py index 7ac17242db87..bf9197fce99f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py index 950d8d45703a..e75daa66036b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py index 7d5f9c0a6f5c..cb154e1ce529 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py @@ -66,11 +66,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py index 98b0b1af0c0a..e5c4b57a1731 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task.py b/samples/openapi3/client/petstore/python/petstore_api/models/task.py index 96d97d9f7a49..68ad30765acc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task.py @@ -53,11 +53,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py index 9cd8fbea443a..4039342bc999 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py index 5ca5c3e784bc..93d9932f5b99 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py index 6d2f433ff86b..d67bb5ef1f35 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py index fb06bb71d49d..36ecd8a5abbb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py @@ -69,11 +69,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py index fb36fcfb6b3c..427a35ab86d8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py index fcdedb28e213..897f0f0b897f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 0c691226512c..5f8e42159a24 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -51,11 +51,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index dcb2075d28e5..c4e874f931ca 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py index 9ec0e57db5af..fefa4c26d8f9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -50,11 +50,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/user.py b/samples/openapi3/client/petstore/python/petstore_api/models/user.py index ffd82e303275..a65ce66ddb99 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/user.py @@ -57,11 +57,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py index 5e42d47d9c42..d1d79b8f0b04 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py @@ -54,11 +54,11 @@ def from_json(cls, json_str: str) -> Self: def to_dict(self) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True) + return self.model_dump(by_alias=True, exclude_unset=True) def to_json(self) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_none=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" diff --git a/samples/openapi3/client/petstore/python/uv.lock b/samples/openapi3/client/petstore/python/uv.lock new file mode 100644 index 000000000000..b69bb2b44825 --- /dev/null +++ b/samples/openapi3/client/petstore/python/uv.lock @@ -0,0 +1,281 @@ +version = 1 +revision = 3 +requires-python = ">=3.9" + +[[package]] +name = "annotated-types" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" }, +] + +[[package]] +name = "pem" +version = "23.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/05/86/16c0b6789816f8d53f2f208b5a090c9197da8a6dae4d490554bb1bedbb09/pem-23.1.0.tar.gz", hash = "sha256:06503ff2441a111f853ce4e8b9eb9d5fedb488ebdbf560115d3dd53a1b4afc73", size = 43796, upload-time = "2023-06-21T10:24:40.539Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c9/97/8299a481ae6c08494b5d53511e6a4746775d8a354c685c69d8796b2ed482/pem-23.1.0-py3-none-any.whl", hash = "sha256:78bbb1e75b737891350cb9499cbba31da5d59545f360f44163c0bc751cad55d3", size = 9195, upload-time = "2023-06-21T10:24:39.164Z" }, +] + +[[package]] +name = "petstore-api" +version = "1.0.0" +source = { editable = "." } +dependencies = [ + { name = "pem" }, + { name = "pycryptodome" }, + { name = "pydantic" }, + { name = "python-dateutil" }, + { name = "typing-extensions" }, + { name = "urllib3" }, +] + +[package.metadata] +requires-dist = [ + { name = "pem", specifier = ">=19.3.0" }, + { name = "pycryptodome", specifier = ">=3.9.0" }, + { name = "pydantic", specifier = ">=2" }, + { name = "python-dateutil", specifier = ">=2.8.2" }, + { name = "typing-extensions", specifier = ">=4.7.1" }, + { name = "urllib3", specifier = ">=2.1.0,<3.0.0" }, +] + +[[package]] +name = "pycryptodome" +version = "3.23.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/8e/a6/8452177684d5e906854776276ddd34eca30d1b1e15aa1ee9cefc289a33f5/pycryptodome-3.23.0.tar.gz", hash = "sha256:447700a657182d60338bab09fdb27518f8856aecd80ae4c6bdddb67ff5da44ef", size = 4921276, upload-time = "2025-05-17T17:21:45.242Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/5d/bdb09489b63cd34a976cc9e2a8d938114f7a53a74d3dd4f125ffa49dce82/pycryptodome-3.23.0-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:0011f7f00cdb74879142011f95133274741778abba114ceca229adbf8e62c3e4", size = 2495152, upload-time = "2025-05-17T17:20:20.833Z" }, + { url = "https://files.pythonhosted.org/packages/a7/ce/7840250ed4cc0039c433cd41715536f926d6e86ce84e904068eb3244b6a6/pycryptodome-3.23.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:90460fc9e088ce095f9ee8356722d4f10f86e5be06e2354230a9880b9c549aae", size = 1639348, upload-time = "2025-05-17T17:20:23.171Z" }, + { url = "https://files.pythonhosted.org/packages/ee/f0/991da24c55c1f688d6a3b5a11940567353f74590734ee4a64294834ae472/pycryptodome-3.23.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4764e64b269fc83b00f682c47443c2e6e85b18273712b98aa43bcb77f8570477", size = 2184033, upload-time = "2025-05-17T17:20:25.424Z" }, + { url = "https://files.pythonhosted.org/packages/54/16/0e11882deddf00f68b68dd4e8e442ddc30641f31afeb2bc25588124ac8de/pycryptodome-3.23.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eb8f24adb74984aa0e5d07a2368ad95276cf38051fe2dc6605cbcf482e04f2a7", size = 2270142, upload-time = "2025-05-17T17:20:27.808Z" }, + { url = "https://files.pythonhosted.org/packages/d5/fc/4347fea23a3f95ffb931f383ff28b3f7b1fe868739182cb76718c0da86a1/pycryptodome-3.23.0-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d97618c9c6684a97ef7637ba43bdf6663a2e2e77efe0f863cce97a76af396446", size = 2309384, upload-time = "2025-05-17T17:20:30.765Z" }, + { url = "https://files.pythonhosted.org/packages/6e/d9/c5261780b69ce66d8cfab25d2797bd6e82ba0241804694cd48be41add5eb/pycryptodome-3.23.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:9a53a4fe5cb075075d515797d6ce2f56772ea7e6a1e5e4b96cf78a14bac3d265", size = 2183237, upload-time = "2025-05-17T17:20:33.736Z" }, + { url = "https://files.pythonhosted.org/packages/5a/6f/3af2ffedd5cfa08c631f89452c6648c4d779e7772dfc388c77c920ca6bbf/pycryptodome-3.23.0-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:763d1d74f56f031788e5d307029caef067febf890cd1f8bf61183ae142f1a77b", size = 2343898, upload-time = "2025-05-17T17:20:36.086Z" }, + { url = "https://files.pythonhosted.org/packages/9a/dc/9060d807039ee5de6e2f260f72f3d70ac213993a804f5e67e0a73a56dd2f/pycryptodome-3.23.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:954af0e2bd7cea83ce72243b14e4fb518b18f0c1649b576d114973e2073b273d", size = 2269197, upload-time = "2025-05-17T17:20:38.414Z" }, + { url = "https://files.pythonhosted.org/packages/f9/34/e6c8ca177cb29dcc4967fef73f5de445912f93bd0343c9c33c8e5bf8cde8/pycryptodome-3.23.0-cp313-cp313t-win32.whl", hash = "sha256:257bb3572c63ad8ba40b89f6fc9d63a2a628e9f9708d31ee26560925ebe0210a", size = 1768600, upload-time = "2025-05-17T17:20:40.688Z" }, + { url = "https://files.pythonhosted.org/packages/e4/1d/89756b8d7ff623ad0160f4539da571d1f594d21ee6d68be130a6eccb39a4/pycryptodome-3.23.0-cp313-cp313t-win_amd64.whl", hash = "sha256:6501790c5b62a29fcb227bd6b62012181d886a767ce9ed03b303d1f22eb5c625", size = 1799740, upload-time = "2025-05-17T17:20:42.413Z" }, + { url = "https://files.pythonhosted.org/packages/5d/61/35a64f0feaea9fd07f0d91209e7be91726eb48c0f1bfc6720647194071e4/pycryptodome-3.23.0-cp313-cp313t-win_arm64.whl", hash = "sha256:9a77627a330ab23ca43b48b130e202582e91cc69619947840ea4d2d1be21eb39", size = 1703685, upload-time = "2025-05-17T17:20:44.388Z" }, + { url = "https://files.pythonhosted.org/packages/db/6c/a1f71542c969912bb0e106f64f60a56cc1f0fabecf9396f45accbe63fa68/pycryptodome-3.23.0-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:187058ab80b3281b1de11c2e6842a357a1f71b42cb1e15bce373f3d238135c27", size = 2495627, upload-time = "2025-05-17T17:20:47.139Z" }, + { url = "https://files.pythonhosted.org/packages/6e/4e/a066527e079fc5002390c8acdd3aca431e6ea0a50ffd7201551175b47323/pycryptodome-3.23.0-cp37-abi3-macosx_10_9_x86_64.whl", hash = "sha256:cfb5cd445280c5b0a4e6187a7ce8de5a07b5f3f897f235caa11f1f435f182843", size = 1640362, upload-time = "2025-05-17T17:20:50.392Z" }, + { url = "https://files.pythonhosted.org/packages/50/52/adaf4c8c100a8c49d2bd058e5b551f73dfd8cb89eb4911e25a0c469b6b4e/pycryptodome-3.23.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:67bd81fcbe34f43ad9422ee8fd4843c8e7198dd88dd3d40e6de42ee65fbe1490", size = 2182625, upload-time = "2025-05-17T17:20:52.866Z" }, + { url = "https://files.pythonhosted.org/packages/5f/e9/a09476d436d0ff1402ac3867d933c61805ec2326c6ea557aeeac3825604e/pycryptodome-3.23.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c8987bd3307a39bc03df5c8e0e3d8be0c4c3518b7f044b0f4c15d1aa78f52575", size = 2268954, upload-time = "2025-05-17T17:20:55.027Z" }, + { url = "https://files.pythonhosted.org/packages/f9/c5/ffe6474e0c551d54cab931918127c46d70cab8f114e0c2b5a3c071c2f484/pycryptodome-3.23.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:aa0698f65e5b570426fc31b8162ed4603b0c2841cbb9088e2b01641e3065915b", size = 2308534, upload-time = "2025-05-17T17:20:57.279Z" }, + { url = "https://files.pythonhosted.org/packages/18/28/e199677fc15ecf43010f2463fde4c1a53015d1fe95fb03bca2890836603a/pycryptodome-3.23.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:53ecbafc2b55353edcebd64bf5da94a2a2cdf5090a6915bcca6eca6cc452585a", size = 2181853, upload-time = "2025-05-17T17:20:59.322Z" }, + { url = "https://files.pythonhosted.org/packages/ce/ea/4fdb09f2165ce1365c9eaefef36625583371ee514db58dc9b65d3a255c4c/pycryptodome-3.23.0-cp37-abi3-musllinux_1_2_i686.whl", hash = "sha256:156df9667ad9f2ad26255926524e1c136d6664b741547deb0a86a9acf5ea631f", size = 2342465, upload-time = "2025-05-17T17:21:03.83Z" }, + { url = "https://files.pythonhosted.org/packages/22/82/6edc3fc42fe9284aead511394bac167693fb2b0e0395b28b8bedaa07ef04/pycryptodome-3.23.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:dea827b4d55ee390dc89b2afe5927d4308a8b538ae91d9c6f7a5090f397af1aa", size = 2267414, upload-time = "2025-05-17T17:21:06.72Z" }, + { url = "https://files.pythonhosted.org/packages/59/fe/aae679b64363eb78326c7fdc9d06ec3de18bac68be4b612fc1fe8902693c/pycryptodome-3.23.0-cp37-abi3-win32.whl", hash = "sha256:507dbead45474b62b2bbe318eb1c4c8ee641077532067fec9c1aa82c31f84886", size = 1768484, upload-time = "2025-05-17T17:21:08.535Z" }, + { url = "https://files.pythonhosted.org/packages/54/2f/e97a1b8294db0daaa87012c24a7bb714147c7ade7656973fd6c736b484ff/pycryptodome-3.23.0-cp37-abi3-win_amd64.whl", hash = "sha256:c75b52aacc6c0c260f204cbdd834f76edc9fb0d8e0da9fbf8352ef58202564e2", size = 1799636, upload-time = "2025-05-17T17:21:10.393Z" }, + { url = "https://files.pythonhosted.org/packages/18/3d/f9441a0d798bf2b1e645adc3265e55706aead1255ccdad3856dbdcffec14/pycryptodome-3.23.0-cp37-abi3-win_arm64.whl", hash = "sha256:11eeeb6917903876f134b56ba11abe95c0b0fd5e3330def218083c7d98bbcb3c", size = 1703675, upload-time = "2025-05-17T17:21:13.146Z" }, + { url = "https://files.pythonhosted.org/packages/d9/12/e33935a0709c07de084d7d58d330ec3f4daf7910a18e77937affdb728452/pycryptodome-3.23.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:ddb95b49df036ddd264a0ad246d1be5b672000f12d6961ea2c267083a5e19379", size = 1623886, upload-time = "2025-05-17T17:21:20.614Z" }, + { url = "https://files.pythonhosted.org/packages/22/0b/aa8f9419f25870889bebf0b26b223c6986652bdf071f000623df11212c90/pycryptodome-3.23.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8e95564beb8782abfd9e431c974e14563a794a4944c29d6d3b7b5ea042110b4", size = 1672151, upload-time = "2025-05-17T17:21:22.666Z" }, + { url = "https://files.pythonhosted.org/packages/d4/5e/63f5cbde2342b7f70a39e591dbe75d9809d6338ce0b07c10406f1a140cdc/pycryptodome-3.23.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14e15c081e912c4b0d75632acd8382dfce45b258667aa3c67caf7a4d4c13f630", size = 1664461, upload-time = "2025-05-17T17:21:25.225Z" }, + { url = "https://files.pythonhosted.org/packages/d6/92/608fbdad566ebe499297a86aae5f2a5263818ceeecd16733006f1600403c/pycryptodome-3.23.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a7fc76bf273353dc7e5207d172b83f569540fc9a28d63171061c42e361d22353", size = 1702440, upload-time = "2025-05-17T17:21:27.991Z" }, + { url = "https://files.pythonhosted.org/packages/d1/92/2eadd1341abd2989cce2e2740b4423608ee2014acb8110438244ee97d7ff/pycryptodome-3.23.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:45c69ad715ca1a94f778215a11e66b7ff989d792a4d63b68dc586a1da1392ff5", size = 1803005, upload-time = "2025-05-17T17:21:31.37Z" }, + { url = "https://files.pythonhosted.org/packages/dc/c4/6925ad41576d3e84f03aaf9a0411667af861f9fa2c87553c7dd5bde01518/pycryptodome-3.23.0-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:865d83c906b0fc6a59b510deceee656b6bc1c4fa0d82176e2b77e97a420a996a", size = 1623768, upload-time = "2025-05-17T17:21:33.418Z" }, + { url = "https://files.pythonhosted.org/packages/a8/14/d6c6a3098ddf2624068f041c5639be5092ad4ae1a411842369fd56765994/pycryptodome-3.23.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:89d4d56153efc4d81defe8b65fd0821ef8b2d5ddf8ed19df31ba2f00872b8002", size = 1672070, upload-time = "2025-05-17T17:21:35.565Z" }, + { url = "https://files.pythonhosted.org/packages/20/89/5d29c8f178fea7c92fd20d22f9ddd532a5e3ac71c574d555d2362aaa832a/pycryptodome-3.23.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e3f2d0aaf8080bda0587d58fc9fe4766e012441e2eed4269a77de6aea981c8be", size = 1664359, upload-time = "2025-05-17T17:21:37.551Z" }, + { url = "https://files.pythonhosted.org/packages/38/bc/a287d41b4421ad50eafb02313137d0276d6aeffab90a91e2b08f64140852/pycryptodome-3.23.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:64093fc334c1eccfd3933c134c4457c34eaca235eeae49d69449dc4728079339", size = 1702359, upload-time = "2025-05-17T17:21:39.827Z" }, + { url = "https://files.pythonhosted.org/packages/2b/62/2392b7879f4d2c1bfa20815720b89d464687877851716936b9609959c201/pycryptodome-3.23.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:ce64e84a962b63a47a592690bdc16a7eaf709d2c2697ababf24a0def566899a6", size = 1802461, upload-time = "2025-05-17T17:21:41.722Z" }, +] + +[[package]] +name = "pydantic" +version = "2.12.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-types" }, + { name = "pydantic-core" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/69/44/36f1a6e523abc58ae5f928898e4aca2e0ea509b5aa6f6f392a5d882be928/pydantic-2.12.5.tar.gz", hash = "sha256:4d351024c75c0f085a9febbb665ce8c0c6ec5d30e903bdb6394b7ede26aebb49", size = 821591, upload-time = "2025-11-26T15:11:46.471Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5a/87/b70ad306ebb6f9b585f114d0ac2137d792b48be34d732d60e597c2f8465a/pydantic-2.12.5-py3-none-any.whl", hash = "sha256:e561593fccf61e8a20fc46dfc2dfe075b8be7d0188df33f221ad1f0139180f9d", size = 463580, upload-time = "2025-11-26T15:11:44.605Z" }, +] + +[[package]] +name = "pydantic-core" +version = "2.41.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/71/70/23b021c950c2addd24ec408e9ab05d59b035b39d97cdc1130e1bce647bb6/pydantic_core-2.41.5.tar.gz", hash = "sha256:08daa51ea16ad373ffd5e7606252cc32f07bc72b28284b6bc9c6df804816476e", size = 460952, upload-time = "2025-11-04T13:43:49.098Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c6/90/32c9941e728d564b411d574d8ee0cf09b12ec978cb22b294995bae5549a5/pydantic_core-2.41.5-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:77b63866ca88d804225eaa4af3e664c5faf3568cea95360d21f4725ab6e07146", size = 2107298, upload-time = "2025-11-04T13:39:04.116Z" }, + { url = "https://files.pythonhosted.org/packages/fb/a8/61c96a77fe28993d9a6fb0f4127e05430a267b235a124545d79fea46dd65/pydantic_core-2.41.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:dfa8a0c812ac681395907e71e1274819dec685fec28273a28905df579ef137e2", size = 1901475, upload-time = "2025-11-04T13:39:06.055Z" }, + { url = "https://files.pythonhosted.org/packages/5d/b6/338abf60225acc18cdc08b4faef592d0310923d19a87fba1faf05af5346e/pydantic_core-2.41.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5921a4d3ca3aee735d9fd163808f5e8dd6c6972101e4adbda9a4667908849b97", size = 1918815, upload-time = "2025-11-04T13:39:10.41Z" }, + { url = "https://files.pythonhosted.org/packages/d1/1c/2ed0433e682983d8e8cba9c8d8ef274d4791ec6a6f24c58935b90e780e0a/pydantic_core-2.41.5-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e25c479382d26a2a41b7ebea1043564a937db462816ea07afa8a44c0866d52f9", size = 2065567, upload-time = "2025-11-04T13:39:12.244Z" }, + { url = "https://files.pythonhosted.org/packages/b3/24/cf84974ee7d6eae06b9e63289b7b8f6549d416b5c199ca2d7ce13bbcf619/pydantic_core-2.41.5-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f547144f2966e1e16ae626d8ce72b4cfa0caedc7fa28052001c94fb2fcaa1c52", size = 2230442, upload-time = "2025-11-04T13:39:13.962Z" }, + { url = "https://files.pythonhosted.org/packages/fd/21/4e287865504b3edc0136c89c9c09431be326168b1eb7841911cbc877a995/pydantic_core-2.41.5-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6f52298fbd394f9ed112d56f3d11aabd0d5bd27beb3084cc3d8ad069483b8941", size = 2350956, upload-time = "2025-11-04T13:39:15.889Z" }, + { url = "https://files.pythonhosted.org/packages/a8/76/7727ef2ffa4b62fcab916686a68a0426b9b790139720e1934e8ba797e238/pydantic_core-2.41.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:100baa204bb412b74fe285fb0f3a385256dad1d1879f0a5cb1499ed2e83d132a", size = 2068253, upload-time = "2025-11-04T13:39:17.403Z" }, + { url = "https://files.pythonhosted.org/packages/d5/8c/a4abfc79604bcb4c748e18975c44f94f756f08fb04218d5cb87eb0d3a63e/pydantic_core-2.41.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:05a2c8852530ad2812cb7914dc61a1125dc4e06252ee98e5638a12da6cc6fb6c", size = 2177050, upload-time = "2025-11-04T13:39:19.351Z" }, + { url = "https://files.pythonhosted.org/packages/67/b1/de2e9a9a79b480f9cb0b6e8b6ba4c50b18d4e89852426364c66aa82bb7b3/pydantic_core-2.41.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:29452c56df2ed968d18d7e21f4ab0ac55e71dc59524872f6fc57dcf4a3249ed2", size = 2147178, upload-time = "2025-11-04T13:39:21Z" }, + { url = "https://files.pythonhosted.org/packages/16/c1/dfb33f837a47b20417500efaa0378adc6635b3c79e8369ff7a03c494b4ac/pydantic_core-2.41.5-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:d5160812ea7a8a2ffbe233d8da666880cad0cbaf5d4de74ae15c313213d62556", size = 2341833, upload-time = "2025-11-04T13:39:22.606Z" }, + { url = "https://files.pythonhosted.org/packages/47/36/00f398642a0f4b815a9a558c4f1dca1b4020a7d49562807d7bc9ff279a6c/pydantic_core-2.41.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:df3959765b553b9440adfd3c795617c352154e497a4eaf3752555cfb5da8fc49", size = 2321156, upload-time = "2025-11-04T13:39:25.843Z" }, + { url = "https://files.pythonhosted.org/packages/7e/70/cad3acd89fde2010807354d978725ae111ddf6d0ea46d1ea1775b5c1bd0c/pydantic_core-2.41.5-cp310-cp310-win32.whl", hash = "sha256:1f8d33a7f4d5a7889e60dc39856d76d09333d8a6ed0f5f1190635cbec70ec4ba", size = 1989378, upload-time = "2025-11-04T13:39:27.92Z" }, + { url = "https://files.pythonhosted.org/packages/76/92/d338652464c6c367e5608e4488201702cd1cbb0f33f7b6a85a60fe5f3720/pydantic_core-2.41.5-cp310-cp310-win_amd64.whl", hash = "sha256:62de39db01b8d593e45871af2af9e497295db8d73b085f6bfd0b18c83c70a8f9", size = 2013622, upload-time = "2025-11-04T13:39:29.848Z" }, + { url = "https://files.pythonhosted.org/packages/e8/72/74a989dd9f2084b3d9530b0915fdda64ac48831c30dbf7c72a41a5232db8/pydantic_core-2.41.5-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:a3a52f6156e73e7ccb0f8cced536adccb7042be67cb45f9562e12b319c119da6", size = 2105873, upload-time = "2025-11-04T13:39:31.373Z" }, + { url = "https://files.pythonhosted.org/packages/12/44/37e403fd9455708b3b942949e1d7febc02167662bf1a7da5b78ee1ea2842/pydantic_core-2.41.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7f3bf998340c6d4b0c9a2f02d6a400e51f123b59565d74dc60d252ce888c260b", size = 1899826, upload-time = "2025-11-04T13:39:32.897Z" }, + { url = "https://files.pythonhosted.org/packages/33/7f/1d5cab3ccf44c1935a359d51a8a2a9e1a654b744b5e7f80d41b88d501eec/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:378bec5c66998815d224c9ca994f1e14c0c21cb95d2f52b6021cc0b2a58f2a5a", size = 1917869, upload-time = "2025-11-04T13:39:34.469Z" }, + { url = "https://files.pythonhosted.org/packages/6e/6a/30d94a9674a7fe4f4744052ed6c5e083424510be1e93da5bc47569d11810/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e7b576130c69225432866fe2f4a469a85a54ade141d96fd396dffcf607b558f8", size = 2063890, upload-time = "2025-11-04T13:39:36.053Z" }, + { url = "https://files.pythonhosted.org/packages/50/be/76e5d46203fcb2750e542f32e6c371ffa9b8ad17364cf94bb0818dbfb50c/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6cb58b9c66f7e4179a2d5e0f849c48eff5c1fca560994d6eb6543abf955a149e", size = 2229740, upload-time = "2025-11-04T13:39:37.753Z" }, + { url = "https://files.pythonhosted.org/packages/d3/ee/fed784df0144793489f87db310a6bbf8118d7b630ed07aa180d6067e653a/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:88942d3a3dff3afc8288c21e565e476fc278902ae4d6d134f1eeda118cc830b1", size = 2350021, upload-time = "2025-11-04T13:39:40.94Z" }, + { url = "https://files.pythonhosted.org/packages/c8/be/8fed28dd0a180dca19e72c233cbf58efa36df055e5b9d90d64fd1740b828/pydantic_core-2.41.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f31d95a179f8d64d90f6831d71fa93290893a33148d890ba15de25642c5d075b", size = 2066378, upload-time = "2025-11-04T13:39:42.523Z" }, + { url = "https://files.pythonhosted.org/packages/b0/3b/698cf8ae1d536a010e05121b4958b1257f0b5522085e335360e53a6b1c8b/pydantic_core-2.41.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:c1df3d34aced70add6f867a8cf413e299177e0c22660cc767218373d0779487b", size = 2175761, upload-time = "2025-11-04T13:39:44.553Z" }, + { url = "https://files.pythonhosted.org/packages/b8/ba/15d537423939553116dea94ce02f9c31be0fa9d0b806d427e0308ec17145/pydantic_core-2.41.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:4009935984bd36bd2c774e13f9a09563ce8de4abaa7226f5108262fa3e637284", size = 2146303, upload-time = "2025-11-04T13:39:46.238Z" }, + { url = "https://files.pythonhosted.org/packages/58/7f/0de669bf37d206723795f9c90c82966726a2ab06c336deba4735b55af431/pydantic_core-2.41.5-cp311-cp311-musllinux_1_1_armv7l.whl", hash = "sha256:34a64bc3441dc1213096a20fe27e8e128bd3ff89921706e83c0b1ac971276594", size = 2340355, upload-time = "2025-11-04T13:39:48.002Z" }, + { url = "https://files.pythonhosted.org/packages/e5/de/e7482c435b83d7e3c3ee5ee4451f6e8973cff0eb6007d2872ce6383f6398/pydantic_core-2.41.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:c9e19dd6e28fdcaa5a1de679aec4141f691023916427ef9bae8584f9c2fb3b0e", size = 2319875, upload-time = "2025-11-04T13:39:49.705Z" }, + { url = "https://files.pythonhosted.org/packages/fe/e6/8c9e81bb6dd7560e33b9053351c29f30c8194b72f2d6932888581f503482/pydantic_core-2.41.5-cp311-cp311-win32.whl", hash = "sha256:2c010c6ded393148374c0f6f0bf89d206bf3217f201faa0635dcd56bd1520f6b", size = 1987549, upload-time = "2025-11-04T13:39:51.842Z" }, + { url = "https://files.pythonhosted.org/packages/11/66/f14d1d978ea94d1bc21fc98fcf570f9542fe55bfcc40269d4e1a21c19bf7/pydantic_core-2.41.5-cp311-cp311-win_amd64.whl", hash = "sha256:76ee27c6e9c7f16f47db7a94157112a2f3a00e958bc626e2f4ee8bec5c328fbe", size = 2011305, upload-time = "2025-11-04T13:39:53.485Z" }, + { url = "https://files.pythonhosted.org/packages/56/d8/0e271434e8efd03186c5386671328154ee349ff0354d83c74f5caaf096ed/pydantic_core-2.41.5-cp311-cp311-win_arm64.whl", hash = "sha256:4bc36bbc0b7584de96561184ad7f012478987882ebf9f9c389b23f432ea3d90f", size = 1972902, upload-time = "2025-11-04T13:39:56.488Z" }, + { url = "https://files.pythonhosted.org/packages/5f/5d/5f6c63eebb5afee93bcaae4ce9a898f3373ca23df3ccaef086d0233a35a7/pydantic_core-2.41.5-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:f41a7489d32336dbf2199c8c0a215390a751c5b014c2c1c5366e817202e9cdf7", size = 2110990, upload-time = "2025-11-04T13:39:58.079Z" }, + { url = "https://files.pythonhosted.org/packages/aa/32/9c2e8ccb57c01111e0fd091f236c7b371c1bccea0fa85247ac55b1e2b6b6/pydantic_core-2.41.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:070259a8818988b9a84a449a2a7337c7f430a22acc0859c6b110aa7212a6d9c0", size = 1896003, upload-time = "2025-11-04T13:39:59.956Z" }, + { url = "https://files.pythonhosted.org/packages/68/b8/a01b53cb0e59139fbc9e4fda3e9724ede8de279097179be4ff31f1abb65a/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e96cea19e34778f8d59fe40775a7a574d95816eb150850a85a7a4c8f4b94ac69", size = 1919200, upload-time = "2025-11-04T13:40:02.241Z" }, + { url = "https://files.pythonhosted.org/packages/38/de/8c36b5198a29bdaade07b5985e80a233a5ac27137846f3bc2d3b40a47360/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ed2e99c456e3fadd05c991f8f437ef902e00eedf34320ba2b0842bd1c3ca3a75", size = 2052578, upload-time = "2025-11-04T13:40:04.401Z" }, + { url = "https://files.pythonhosted.org/packages/00/b5/0e8e4b5b081eac6cb3dbb7e60a65907549a1ce035a724368c330112adfdd/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:65840751b72fbfd82c3c640cff9284545342a4f1eb1586ad0636955b261b0b05", size = 2208504, upload-time = "2025-11-04T13:40:06.072Z" }, + { url = "https://files.pythonhosted.org/packages/77/56/87a61aad59c7c5b9dc8caad5a41a5545cba3810c3e828708b3d7404f6cef/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e536c98a7626a98feb2d3eaf75944ef6f3dbee447e1f841eae16f2f0a72d8ddc", size = 2335816, upload-time = "2025-11-04T13:40:07.835Z" }, + { url = "https://files.pythonhosted.org/packages/0d/76/941cc9f73529988688a665a5c0ecff1112b3d95ab48f81db5f7606f522d3/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eceb81a8d74f9267ef4081e246ffd6d129da5d87e37a77c9bde550cb04870c1c", size = 2075366, upload-time = "2025-11-04T13:40:09.804Z" }, + { url = "https://files.pythonhosted.org/packages/d3/43/ebef01f69baa07a482844faaa0a591bad1ef129253ffd0cdaa9d8a7f72d3/pydantic_core-2.41.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d38548150c39b74aeeb0ce8ee1d8e82696f4a4e16ddc6de7b1d8823f7de4b9b5", size = 2171698, upload-time = "2025-11-04T13:40:12.004Z" }, + { url = "https://files.pythonhosted.org/packages/b1/87/41f3202e4193e3bacfc2c065fab7706ebe81af46a83d3e27605029c1f5a6/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c23e27686783f60290e36827f9c626e63154b82b116d7fe9adba1fda36da706c", size = 2132603, upload-time = "2025-11-04T13:40:13.868Z" }, + { url = "https://files.pythonhosted.org/packages/49/7d/4c00df99cb12070b6bccdef4a195255e6020a550d572768d92cc54dba91a/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:482c982f814460eabe1d3bb0adfdc583387bd4691ef00b90575ca0d2b6fe2294", size = 2329591, upload-time = "2025-11-04T13:40:15.672Z" }, + { url = "https://files.pythonhosted.org/packages/cc/6a/ebf4b1d65d458f3cda6a7335d141305dfa19bdc61140a884d165a8a1bbc7/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:bfea2a5f0b4d8d43adf9d7b8bf019fb46fdd10a2e5cde477fbcb9d1fa08c68e1", size = 2319068, upload-time = "2025-11-04T13:40:17.532Z" }, + { url = "https://files.pythonhosted.org/packages/49/3b/774f2b5cd4192d5ab75870ce4381fd89cf218af999515baf07e7206753f0/pydantic_core-2.41.5-cp312-cp312-win32.whl", hash = "sha256:b74557b16e390ec12dca509bce9264c3bbd128f8a2c376eaa68003d7f327276d", size = 1985908, upload-time = "2025-11-04T13:40:19.309Z" }, + { url = "https://files.pythonhosted.org/packages/86/45/00173a033c801cacf67c190fef088789394feaf88a98a7035b0e40d53dc9/pydantic_core-2.41.5-cp312-cp312-win_amd64.whl", hash = "sha256:1962293292865bca8e54702b08a4f26da73adc83dd1fcf26fbc875b35d81c815", size = 2020145, upload-time = "2025-11-04T13:40:21.548Z" }, + { url = "https://files.pythonhosted.org/packages/f9/22/91fbc821fa6d261b376a3f73809f907cec5ca6025642c463d3488aad22fb/pydantic_core-2.41.5-cp312-cp312-win_arm64.whl", hash = "sha256:1746d4a3d9a794cacae06a5eaaccb4b8643a131d45fbc9af23e353dc0a5ba5c3", size = 1976179, upload-time = "2025-11-04T13:40:23.393Z" }, + { url = "https://files.pythonhosted.org/packages/87/06/8806241ff1f70d9939f9af039c6c35f2360cf16e93c2ca76f184e76b1564/pydantic_core-2.41.5-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:941103c9be18ac8daf7b7adca8228f8ed6bb7a1849020f643b3a14d15b1924d9", size = 2120403, upload-time = "2025-11-04T13:40:25.248Z" }, + { url = "https://files.pythonhosted.org/packages/94/02/abfa0e0bda67faa65fef1c84971c7e45928e108fe24333c81f3bfe35d5f5/pydantic_core-2.41.5-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:112e305c3314f40c93998e567879e887a3160bb8689ef3d2c04b6cc62c33ac34", size = 1896206, upload-time = "2025-11-04T13:40:27.099Z" }, + { url = "https://files.pythonhosted.org/packages/15/df/a4c740c0943e93e6500f9eb23f4ca7ec9bf71b19e608ae5b579678c8d02f/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0cbaad15cb0c90aa221d43c00e77bb33c93e8d36e0bf74760cd00e732d10a6a0", size = 1919307, upload-time = "2025-11-04T13:40:29.806Z" }, + { url = "https://files.pythonhosted.org/packages/9a/e3/6324802931ae1d123528988e0e86587c2072ac2e5394b4bc2bc34b61ff6e/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:03ca43e12fab6023fc79d28ca6b39b05f794ad08ec2feccc59a339b02f2b3d33", size = 2063258, upload-time = "2025-11-04T13:40:33.544Z" }, + { url = "https://files.pythonhosted.org/packages/c9/d4/2230d7151d4957dd79c3044ea26346c148c98fbf0ee6ebd41056f2d62ab5/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dc799088c08fa04e43144b164feb0c13f9a0bc40503f8df3e9fde58a3c0c101e", size = 2214917, upload-time = "2025-11-04T13:40:35.479Z" }, + { url = "https://files.pythonhosted.org/packages/e6/9f/eaac5df17a3672fef0081b6c1bb0b82b33ee89aa5cec0d7b05f52fd4a1fa/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:97aeba56665b4c3235a0e52b2c2f5ae9cd071b8a8310ad27bddb3f7fb30e9aa2", size = 2332186, upload-time = "2025-11-04T13:40:37.436Z" }, + { url = "https://files.pythonhosted.org/packages/cf/4e/35a80cae583a37cf15604b44240e45c05e04e86f9cfd766623149297e971/pydantic_core-2.41.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:406bf18d345822d6c21366031003612b9c77b3e29ffdb0f612367352aab7d586", size = 2073164, upload-time = "2025-11-04T13:40:40.289Z" }, + { url = "https://files.pythonhosted.org/packages/bf/e3/f6e262673c6140dd3305d144d032f7bd5f7497d3871c1428521f19f9efa2/pydantic_core-2.41.5-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b93590ae81f7010dbe380cdeab6f515902ebcbefe0b9327cc4804d74e93ae69d", size = 2179146, upload-time = "2025-11-04T13:40:42.809Z" }, + { url = "https://files.pythonhosted.org/packages/75/c7/20bd7fc05f0c6ea2056a4565c6f36f8968c0924f19b7d97bbfea55780e73/pydantic_core-2.41.5-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:01a3d0ab748ee531f4ea6c3e48ad9dac84ddba4b0d82291f87248f2f9de8d740", size = 2137788, upload-time = "2025-11-04T13:40:44.752Z" }, + { url = "https://files.pythonhosted.org/packages/3a/8d/34318ef985c45196e004bc46c6eab2eda437e744c124ef0dbe1ff2c9d06b/pydantic_core-2.41.5-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:6561e94ba9dacc9c61bce40e2d6bdc3bfaa0259d3ff36ace3b1e6901936d2e3e", size = 2340133, upload-time = "2025-11-04T13:40:46.66Z" }, + { url = "https://files.pythonhosted.org/packages/9c/59/013626bf8c78a5a5d9350d12e7697d3d4de951a75565496abd40ccd46bee/pydantic_core-2.41.5-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:915c3d10f81bec3a74fbd4faebe8391013ba61e5a1a8d48c4455b923bdda7858", size = 2324852, upload-time = "2025-11-04T13:40:48.575Z" }, + { url = "https://files.pythonhosted.org/packages/1a/d9/c248c103856f807ef70c18a4f986693a46a8ffe1602e5d361485da502d20/pydantic_core-2.41.5-cp313-cp313-win32.whl", hash = "sha256:650ae77860b45cfa6e2cdafc42618ceafab3a2d9a3811fcfbd3bbf8ac3c40d36", size = 1994679, upload-time = "2025-11-04T13:40:50.619Z" }, + { url = "https://files.pythonhosted.org/packages/9e/8b/341991b158ddab181cff136acd2552c9f35bd30380422a639c0671e99a91/pydantic_core-2.41.5-cp313-cp313-win_amd64.whl", hash = "sha256:79ec52ec461e99e13791ec6508c722742ad745571f234ea6255bed38c6480f11", size = 2019766, upload-time = "2025-11-04T13:40:52.631Z" }, + { url = "https://files.pythonhosted.org/packages/73/7d/f2f9db34af103bea3e09735bb40b021788a5e834c81eedb541991badf8f5/pydantic_core-2.41.5-cp313-cp313-win_arm64.whl", hash = "sha256:3f84d5c1b4ab906093bdc1ff10484838aca54ef08de4afa9de0f5f14d69639cd", size = 1981005, upload-time = "2025-11-04T13:40:54.734Z" }, + { url = "https://files.pythonhosted.org/packages/ea/28/46b7c5c9635ae96ea0fbb779e271a38129df2550f763937659ee6c5dbc65/pydantic_core-2.41.5-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:3f37a19d7ebcdd20b96485056ba9e8b304e27d9904d233d7b1015db320e51f0a", size = 2119622, upload-time = "2025-11-04T13:40:56.68Z" }, + { url = "https://files.pythonhosted.org/packages/74/1a/145646e5687e8d9a1e8d09acb278c8535ebe9e972e1f162ed338a622f193/pydantic_core-2.41.5-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:1d1d9764366c73f996edd17abb6d9d7649a7eb690006ab6adbda117717099b14", size = 1891725, upload-time = "2025-11-04T13:40:58.807Z" }, + { url = "https://files.pythonhosted.org/packages/23/04/e89c29e267b8060b40dca97bfc64a19b2a3cf99018167ea1677d96368273/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:25e1c2af0fce638d5f1988b686f3b3ea8cd7de5f244ca147c777769e798a9cd1", size = 1915040, upload-time = "2025-11-04T13:41:00.853Z" }, + { url = "https://files.pythonhosted.org/packages/84/a3/15a82ac7bd97992a82257f777b3583d3e84bdb06ba6858f745daa2ec8a85/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:506d766a8727beef16b7adaeb8ee6217c64fc813646b424d0804d67c16eddb66", size = 2063691, upload-time = "2025-11-04T13:41:03.504Z" }, + { url = "https://files.pythonhosted.org/packages/74/9b/0046701313c6ef08c0c1cf0e028c67c770a4e1275ca73131563c5f2a310a/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4819fa52133c9aa3c387b3328f25c1facc356491e6135b459f1de698ff64d869", size = 2213897, upload-time = "2025-11-04T13:41:05.804Z" }, + { url = "https://files.pythonhosted.org/packages/8a/cd/6bac76ecd1b27e75a95ca3a9a559c643b3afcd2dd62086d4b7a32a18b169/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2b761d210c9ea91feda40d25b4efe82a1707da2ef62901466a42492c028553a2", size = 2333302, upload-time = "2025-11-04T13:41:07.809Z" }, + { url = "https://files.pythonhosted.org/packages/4c/d2/ef2074dc020dd6e109611a8be4449b98cd25e1b9b8a303c2f0fca2f2bcf7/pydantic_core-2.41.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:22f0fb8c1c583a3b6f24df2470833b40207e907b90c928cc8d3594b76f874375", size = 2064877, upload-time = "2025-11-04T13:41:09.827Z" }, + { url = "https://files.pythonhosted.org/packages/18/66/e9db17a9a763d72f03de903883c057b2592c09509ccfe468187f2a2eef29/pydantic_core-2.41.5-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2782c870e99878c634505236d81e5443092fba820f0373997ff75f90f68cd553", size = 2180680, upload-time = "2025-11-04T13:41:12.379Z" }, + { url = "https://files.pythonhosted.org/packages/d3/9e/3ce66cebb929f3ced22be85d4c2399b8e85b622db77dad36b73c5387f8f8/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:0177272f88ab8312479336e1d777f6b124537d47f2123f89cb37e0accea97f90", size = 2138960, upload-time = "2025-11-04T13:41:14.627Z" }, + { url = "https://files.pythonhosted.org/packages/a6/62/205a998f4327d2079326b01abee48e502ea739d174f0a89295c481a2272e/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:63510af5e38f8955b8ee5687740d6ebf7c2a0886d15a6d65c32814613681bc07", size = 2339102, upload-time = "2025-11-04T13:41:16.868Z" }, + { url = "https://files.pythonhosted.org/packages/3c/0d/f05e79471e889d74d3d88f5bd20d0ed189ad94c2423d81ff8d0000aab4ff/pydantic_core-2.41.5-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:e56ba91f47764cc14f1daacd723e3e82d1a89d783f0f5afe9c364b8bb491ccdb", size = 2326039, upload-time = "2025-11-04T13:41:18.934Z" }, + { url = "https://files.pythonhosted.org/packages/ec/e1/e08a6208bb100da7e0c4b288eed624a703f4d129bde2da475721a80cab32/pydantic_core-2.41.5-cp314-cp314-win32.whl", hash = "sha256:aec5cf2fd867b4ff45b9959f8b20ea3993fc93e63c7363fe6851424c8a7e7c23", size = 1995126, upload-time = "2025-11-04T13:41:21.418Z" }, + { url = "https://files.pythonhosted.org/packages/48/5d/56ba7b24e9557f99c9237e29f5c09913c81eeb2f3217e40e922353668092/pydantic_core-2.41.5-cp314-cp314-win_amd64.whl", hash = "sha256:8e7c86f27c585ef37c35e56a96363ab8de4e549a95512445b85c96d3e2f7c1bf", size = 2015489, upload-time = "2025-11-04T13:41:24.076Z" }, + { url = "https://files.pythonhosted.org/packages/4e/bb/f7a190991ec9e3e0ba22e4993d8755bbc4a32925c0b5b42775c03e8148f9/pydantic_core-2.41.5-cp314-cp314-win_arm64.whl", hash = "sha256:e672ba74fbc2dc8eea59fb6d4aed6845e6905fc2a8afe93175d94a83ba2a01a0", size = 1977288, upload-time = "2025-11-04T13:41:26.33Z" }, + { url = "https://files.pythonhosted.org/packages/92/ed/77542d0c51538e32e15afe7899d79efce4b81eee631d99850edc2f5e9349/pydantic_core-2.41.5-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:8566def80554c3faa0e65ac30ab0932b9e3a5cd7f8323764303d468e5c37595a", size = 2120255, upload-time = "2025-11-04T13:41:28.569Z" }, + { url = "https://files.pythonhosted.org/packages/bb/3d/6913dde84d5be21e284439676168b28d8bbba5600d838b9dca99de0fad71/pydantic_core-2.41.5-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:b80aa5095cd3109962a298ce14110ae16b8c1aece8b72f9dafe81cf597ad80b3", size = 1863760, upload-time = "2025-11-04T13:41:31.055Z" }, + { url = "https://files.pythonhosted.org/packages/5a/f0/e5e6b99d4191da102f2b0eb9687aaa7f5bea5d9964071a84effc3e40f997/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3006c3dd9ba34b0c094c544c6006cc79e87d8612999f1a5d43b769b89181f23c", size = 1878092, upload-time = "2025-11-04T13:41:33.21Z" }, + { url = "https://files.pythonhosted.org/packages/71/48/36fb760642d568925953bcc8116455513d6e34c4beaa37544118c36aba6d/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:72f6c8b11857a856bcfa48c86f5368439f74453563f951e473514579d44aa612", size = 2053385, upload-time = "2025-11-04T13:41:35.508Z" }, + { url = "https://files.pythonhosted.org/packages/20/25/92dc684dd8eb75a234bc1c764b4210cf2646479d54b47bf46061657292a8/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5cb1b2f9742240e4bb26b652a5aeb840aa4b417c7748b6f8387927bc6e45e40d", size = 2218832, upload-time = "2025-11-04T13:41:37.732Z" }, + { url = "https://files.pythonhosted.org/packages/e2/09/f53e0b05023d3e30357d82eb35835d0f6340ca344720a4599cd663dca599/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bd3d54f38609ff308209bd43acea66061494157703364ae40c951f83ba99a1a9", size = 2327585, upload-time = "2025-11-04T13:41:40Z" }, + { url = "https://files.pythonhosted.org/packages/aa/4e/2ae1aa85d6af35a39b236b1b1641de73f5a6ac4d5a7509f77b814885760c/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2ff4321e56e879ee8d2a879501c8e469414d948f4aba74a2d4593184eb326660", size = 2041078, upload-time = "2025-11-04T13:41:42.323Z" }, + { url = "https://files.pythonhosted.org/packages/cd/13/2e215f17f0ef326fc72afe94776edb77525142c693767fc347ed6288728d/pydantic_core-2.41.5-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d0d2568a8c11bf8225044aa94409e21da0cb09dcdafe9ecd10250b2baad531a9", size = 2173914, upload-time = "2025-11-04T13:41:45.221Z" }, + { url = "https://files.pythonhosted.org/packages/02/7a/f999a6dcbcd0e5660bc348a3991c8915ce6599f4f2c6ac22f01d7a10816c/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:a39455728aabd58ceabb03c90e12f71fd30fa69615760a075b9fec596456ccc3", size = 2129560, upload-time = "2025-11-04T13:41:47.474Z" }, + { url = "https://files.pythonhosted.org/packages/3a/b1/6c990ac65e3b4c079a4fb9f5b05f5b013afa0f4ed6780a3dd236d2cbdc64/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:239edca560d05757817c13dc17c50766136d21f7cd0fac50295499ae24f90fdf", size = 2329244, upload-time = "2025-11-04T13:41:49.992Z" }, + { url = "https://files.pythonhosted.org/packages/d9/02/3c562f3a51afd4d88fff8dffb1771b30cfdfd79befd9883ee094f5b6c0d8/pydantic_core-2.41.5-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:2a5e06546e19f24c6a96a129142a75cee553cc018ffee48a460059b1185f4470", size = 2331955, upload-time = "2025-11-04T13:41:54.079Z" }, + { url = "https://files.pythonhosted.org/packages/5c/96/5fb7d8c3c17bc8c62fdb031c47d77a1af698f1d7a406b0f79aaa1338f9ad/pydantic_core-2.41.5-cp314-cp314t-win32.whl", hash = "sha256:b4ececa40ac28afa90871c2cc2b9ffd2ff0bf749380fbdf57d165fd23da353aa", size = 1988906, upload-time = "2025-11-04T13:41:56.606Z" }, + { url = "https://files.pythonhosted.org/packages/22/ed/182129d83032702912c2e2d8bbe33c036f342cc735737064668585dac28f/pydantic_core-2.41.5-cp314-cp314t-win_amd64.whl", hash = "sha256:80aa89cad80b32a912a65332f64a4450ed00966111b6615ca6816153d3585a8c", size = 1981607, upload-time = "2025-11-04T13:41:58.889Z" }, + { url = "https://files.pythonhosted.org/packages/9f/ed/068e41660b832bb0b1aa5b58011dea2a3fe0ba7861ff38c4d4904c1c1a99/pydantic_core-2.41.5-cp314-cp314t-win_arm64.whl", hash = "sha256:35b44f37a3199f771c3eaa53051bc8a70cd7b54f333531c59e29fd4db5d15008", size = 1974769, upload-time = "2025-11-04T13:42:01.186Z" }, + { url = "https://files.pythonhosted.org/packages/54/db/160dffb57ed9a3705c4cbcbff0ac03bdae45f1ca7d58ab74645550df3fbd/pydantic_core-2.41.5-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:8bfeaf8735be79f225f3fefab7f941c712aaca36f1128c9d7e2352ee1aa87bdf", size = 2107999, upload-time = "2025-11-04T13:42:03.885Z" }, + { url = "https://files.pythonhosted.org/packages/a3/7d/88e7de946f60d9263cc84819f32513520b85c0f8322f9b8f6e4afc938383/pydantic_core-2.41.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:346285d28e4c8017da95144c7f3acd42740d637ff41946af5ce6e5e420502dd5", size = 1929745, upload-time = "2025-11-04T13:42:06.075Z" }, + { url = "https://files.pythonhosted.org/packages/d5/c2/aef51e5b283780e85e99ff19db0f05842d2d4a8a8cd15e63b0280029b08f/pydantic_core-2.41.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a75dafbf87d6276ddc5b2bf6fae5254e3d0876b626eb24969a574fff9149ee5d", size = 1920220, upload-time = "2025-11-04T13:42:08.457Z" }, + { url = "https://files.pythonhosted.org/packages/c7/97/492ab10f9ac8695cd76b2fdb24e9e61f394051df71594e9bcc891c9f586e/pydantic_core-2.41.5-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:7b93a4d08587e2b7e7882de461e82b6ed76d9026ce91ca7915e740ecc7855f60", size = 2067296, upload-time = "2025-11-04T13:42:10.817Z" }, + { url = "https://files.pythonhosted.org/packages/ec/23/984149650e5269c59a2a4c41d234a9570adc68ab29981825cfaf4cfad8f4/pydantic_core-2.41.5-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e8465ab91a4bd96d36dde3263f06caa6a8a6019e4113f24dc753d79a8b3a3f82", size = 2231548, upload-time = "2025-11-04T13:42:13.843Z" }, + { url = "https://files.pythonhosted.org/packages/71/0c/85bcbb885b9732c28bec67a222dbed5ed2d77baee1f8bba2002e8cd00c5c/pydantic_core-2.41.5-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:299e0a22e7ae2b85c1a57f104538b2656e8ab1873511fd718a1c1c6f149b77b5", size = 2362571, upload-time = "2025-11-04T13:42:16.208Z" }, + { url = "https://files.pythonhosted.org/packages/c0/4a/412d2048be12c334003e9b823a3fa3d038e46cc2d64dd8aab50b31b65499/pydantic_core-2.41.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:707625ef0983fcfb461acfaf14de2067c5942c6bb0f3b4c99158bed6fedd3cf3", size = 2068175, upload-time = "2025-11-04T13:42:18.911Z" }, + { url = "https://files.pythonhosted.org/packages/73/f4/c58b6a776b502d0a5540ad02e232514285513572060f0d78f7832ca3c98b/pydantic_core-2.41.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f41eb9797986d6ebac5e8edff36d5cef9de40def462311b3eb3eeded1431e425", size = 2177203, upload-time = "2025-11-04T13:42:22.578Z" }, + { url = "https://files.pythonhosted.org/packages/ed/ae/f06ea4c7e7a9eead3d165e7623cd2ea0cb788e277e4f935af63fc98fa4e6/pydantic_core-2.41.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0384e2e1021894b1ff5a786dbf94771e2986ebe2869533874d7e43bc79c6f504", size = 2148191, upload-time = "2025-11-04T13:42:24.89Z" }, + { url = "https://files.pythonhosted.org/packages/c1/57/25a11dcdc656bf5f8b05902c3c2934ac3ea296257cc4a3f79a6319e61856/pydantic_core-2.41.5-cp39-cp39-musllinux_1_1_armv7l.whl", hash = "sha256:f0cd744688278965817fd0839c4a4116add48d23890d468bc436f78beb28abf5", size = 2343907, upload-time = "2025-11-04T13:42:27.683Z" }, + { url = "https://files.pythonhosted.org/packages/96/82/e33d5f4933d7a03327c0c43c65d575e5919d4974ffc026bc917a5f7b9f61/pydantic_core-2.41.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:753e230374206729bf0a807954bcc6c150d3743928a73faffee51ac6557a03c3", size = 2322174, upload-time = "2025-11-04T13:42:30.776Z" }, + { url = "https://files.pythonhosted.org/packages/81/45/4091be67ce9f469e81656f880f3506f6a5624121ec5eb3eab37d7581897d/pydantic_core-2.41.5-cp39-cp39-win32.whl", hash = "sha256:873e0d5b4fb9b89ef7c2d2a963ea7d02879d9da0da8d9d4933dee8ee86a8b460", size = 1990353, upload-time = "2025-11-04T13:42:33.111Z" }, + { url = "https://files.pythonhosted.org/packages/44/8a/a98aede18db6e9cd5d66bcacd8a409fcf8134204cdede2e7de35c5a2c5ef/pydantic_core-2.41.5-cp39-cp39-win_amd64.whl", hash = "sha256:e4f4a984405e91527a0d62649ee21138f8e3d0ef103be488c1dc11a80d7f184b", size = 2015698, upload-time = "2025-11-04T13:42:35.484Z" }, + { url = "https://files.pythonhosted.org/packages/11/72/90fda5ee3b97e51c494938a4a44c3a35a9c96c19bba12372fb9c634d6f57/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-macosx_10_12_x86_64.whl", hash = "sha256:b96d5f26b05d03cc60f11a7761a5ded1741da411e7fe0909e27a5e6a0cb7b034", size = 2115441, upload-time = "2025-11-04T13:42:39.557Z" }, + { url = "https://files.pythonhosted.org/packages/1f/53/8942f884fa33f50794f119012dc6a1a02ac43a56407adaac20463df8e98f/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-macosx_11_0_arm64.whl", hash = "sha256:634e8609e89ceecea15e2d61bc9ac3718caaaa71963717bf3c8f38bfde64242c", size = 1930291, upload-time = "2025-11-04T13:42:42.169Z" }, + { url = "https://files.pythonhosted.org/packages/79/c8/ecb9ed9cd942bce09fc888ee960b52654fbdbede4ba6c2d6e0d3b1d8b49c/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:93e8740d7503eb008aa2df04d3b9735f845d43ae845e6dcd2be0b55a2da43cd2", size = 1948632, upload-time = "2025-11-04T13:42:44.564Z" }, + { url = "https://files.pythonhosted.org/packages/2e/1b/687711069de7efa6af934e74f601e2a4307365e8fdc404703afc453eab26/pydantic_core-2.41.5-graalpy311-graalpy242_311_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f15489ba13d61f670dcc96772e733aad1a6f9c429cc27574c6cdaed82d0146ad", size = 2138905, upload-time = "2025-11-04T13:42:47.156Z" }, + { url = "https://files.pythonhosted.org/packages/09/32/59b0c7e63e277fa7911c2fc70ccfb45ce4b98991e7ef37110663437005af/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:7da7087d756b19037bc2c06edc6c170eeef3c3bafcb8f532ff17d64dc427adfd", size = 2110495, upload-time = "2025-11-04T13:42:49.689Z" }, + { url = "https://files.pythonhosted.org/packages/aa/81/05e400037eaf55ad400bcd318c05bb345b57e708887f07ddb2d20e3f0e98/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:aabf5777b5c8ca26f7824cb4a120a740c9588ed58df9b2d196ce92fba42ff8dc", size = 1915388, upload-time = "2025-11-04T13:42:52.215Z" }, + { url = "https://files.pythonhosted.org/packages/6e/0d/e3549b2399f71d56476b77dbf3cf8937cec5cd70536bdc0e374a421d0599/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c007fe8a43d43b3969e8469004e9845944f1a80e6acd47c150856bb87f230c56", size = 1942879, upload-time = "2025-11-04T13:42:56.483Z" }, + { url = "https://files.pythonhosted.org/packages/f7/07/34573da085946b6a313d7c42f82f16e8920bfd730665de2d11c0c37a74b5/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76d0819de158cd855d1cbb8fcafdf6f5cf1eb8e470abe056d5d161106e38062b", size = 2139017, upload-time = "2025-11-04T13:42:59.471Z" }, + { url = "https://files.pythonhosted.org/packages/e6/b0/1a2aa41e3b5a4ba11420aba2d091b2d17959c8d1519ece3627c371951e73/pydantic_core-2.41.5-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b5819cd790dbf0c5eb9f82c73c16b39a65dd6dd4d1439dcdea7816ec9adddab8", size = 2103351, upload-time = "2025-11-04T13:43:02.058Z" }, + { url = "https://files.pythonhosted.org/packages/a4/ee/31b1f0020baaf6d091c87900ae05c6aeae101fa4e188e1613c80e4f1ea31/pydantic_core-2.41.5-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:5a4e67afbc95fa5c34cf27d9089bca7fcab4e51e57278d710320a70b956d1b9a", size = 1925363, upload-time = "2025-11-04T13:43:05.159Z" }, + { url = "https://files.pythonhosted.org/packages/e1/89/ab8e86208467e467a80deaca4e434adac37b10a9d134cd2f99b28a01e483/pydantic_core-2.41.5-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ece5c59f0ce7d001e017643d8d24da587ea1f74f6993467d85ae8a5ef9d4f42b", size = 2135615, upload-time = "2025-11-04T13:43:08.116Z" }, + { url = "https://files.pythonhosted.org/packages/99/0a/99a53d06dd0348b2008f2f30884b34719c323f16c3be4e6cc1203b74a91d/pydantic_core-2.41.5-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:16f80f7abe3351f8ea6858914ddc8c77e02578544a0ebc15b4c2e1a0e813b0b2", size = 2175369, upload-time = "2025-11-04T13:43:12.49Z" }, + { url = "https://files.pythonhosted.org/packages/6d/94/30ca3b73c6d485b9bb0bc66e611cff4a7138ff9736b7e66bcf0852151636/pydantic_core-2.41.5-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:33cb885e759a705b426baada1fe68cbb0a2e68e34c5d0d0289a364cf01709093", size = 2144218, upload-time = "2025-11-04T13:43:15.431Z" }, + { url = "https://files.pythonhosted.org/packages/87/57/31b4f8e12680b739a91f472b5671294236b82586889ef764b5fbc6669238/pydantic_core-2.41.5-pp310-pypy310_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:c8d8b4eb992936023be7dee581270af5c6e0697a8559895f527f5b7105ecd36a", size = 2329951, upload-time = "2025-11-04T13:43:18.062Z" }, + { url = "https://files.pythonhosted.org/packages/7d/73/3c2c8edef77b8f7310e6fb012dbc4b8551386ed575b9eb6fb2506e28a7eb/pydantic_core-2.41.5-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:242a206cd0318f95cd21bdacff3fcc3aab23e79bba5cac3db5a841c9ef9c6963", size = 2318428, upload-time = "2025-11-04T13:43:20.679Z" }, + { url = "https://files.pythonhosted.org/packages/2f/02/8559b1f26ee0d502c74f9cca5c0d2fd97e967e083e006bbbb4e97f3a043a/pydantic_core-2.41.5-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:d3a978c4f57a597908b7e697229d996d77a6d3c94901e9edee593adada95ce1a", size = 2147009, upload-time = "2025-11-04T13:43:23.286Z" }, + { url = "https://files.pythonhosted.org/packages/5f/9b/1b3f0e9f9305839d7e84912f9e8bfbd191ed1b1ef48083609f0dabde978c/pydantic_core-2.41.5-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:b2379fa7ed44ddecb5bfe4e48577d752db9fc10be00a6b7446e9663ba143de26", size = 2101980, upload-time = "2025-11-04T13:43:25.97Z" }, + { url = "https://files.pythonhosted.org/packages/a4/ed/d71fefcb4263df0da6a85b5d8a7508360f2f2e9b3bf5814be9c8bccdccc1/pydantic_core-2.41.5-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:266fb4cbf5e3cbd0b53669a6d1b039c45e3ce651fd5442eff4d07c2cc8d66808", size = 1923865, upload-time = "2025-11-04T13:43:28.763Z" }, + { url = "https://files.pythonhosted.org/packages/ce/3a/626b38db460d675f873e4444b4bb030453bbe7b4ba55df821d026a0493c4/pydantic_core-2.41.5-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:58133647260ea01e4d0500089a8c4f07bd7aa6ce109682b1426394988d8aaacc", size = 2134256, upload-time = "2025-11-04T13:43:31.71Z" }, + { url = "https://files.pythonhosted.org/packages/83/d9/8412d7f06f616bbc053d30cb4e5f76786af3221462ad5eee1f202021eb4e/pydantic_core-2.41.5-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:287dad91cfb551c363dc62899a80e9e14da1f0e2b6ebde82c806612ca2a13ef1", size = 2174762, upload-time = "2025-11-04T13:43:34.744Z" }, + { url = "https://files.pythonhosted.org/packages/55/4c/162d906b8e3ba3a99354e20faa1b49a85206c47de97a639510a0e673f5da/pydantic_core-2.41.5-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:03b77d184b9eb40240ae9fd676ca364ce1085f203e1b1256f8ab9984dca80a84", size = 2143141, upload-time = "2025-11-04T13:43:37.701Z" }, + { url = "https://files.pythonhosted.org/packages/1f/f2/f11dd73284122713f5f89fc940f370d035fa8e1e078d446b3313955157fe/pydantic_core-2.41.5-pp311-pypy311_pp73-musllinux_1_1_armv7l.whl", hash = "sha256:a668ce24de96165bb239160b3d854943128f4334822900534f2fe947930e5770", size = 2330317, upload-time = "2025-11-04T13:43:40.406Z" }, + { url = "https://files.pythonhosted.org/packages/88/9d/b06ca6acfe4abb296110fb1273a4d848a0bfb2ff65f3ee92127b3244e16b/pydantic_core-2.41.5-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f14f8f046c14563f8eb3f45f499cc658ab8d10072961e07225e507adb700e93f", size = 2316992, upload-time = "2025-11-04T13:43:43.602Z" }, + { url = "https://files.pythonhosted.org/packages/36/c7/cfc8e811f061c841d7990b0201912c3556bfeb99cdcb7ed24adc8d6f8704/pydantic_core-2.41.5-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:56121965f7a4dc965bff783d70b907ddf3d57f6eba29b6d2e5dabfaf07799c51", size = 2145302, upload-time = "2025-11-04T13:43:46.64Z" }, +] + +[[package]] +name = "python-dateutil" +version = "2.9.0.post0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size = 342432, upload-time = "2024-03-01T18:36:20.211Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" }, +] + +[[package]] +name = "six" +version = "1.17.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031, upload-time = "2024-12-04T17:35:28.174Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, +] + +[[package]] +name = "typing-inspection" +version = "0.4.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz", hash = "sha256:ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464", size = 75949, upload-time = "2025-10-01T02:14:41.687Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" }, +] + +[[package]] +name = "urllib3" +version = "2.6.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c7/24/5f1b3bdffd70275f6661c76461e25f024d5a38a46f04aaca912426a2b1d3/urllib3-2.6.3.tar.gz", hash = "sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed", size = 435556, upload-time = "2026-01-07T16:24:43.925Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/39/08/aaaad47bc4e9dc8c725e68f9d04865dbcb2052843ff09c97b08904852d84/urllib3-2.6.3-py3-none-any.whl", hash = "sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4", size = 131584, upload-time = "2026-01-07T16:24:42.685Z" }, +] From 1dc59833e51a286b3f5761c41bde18adb6f41078 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Wed, 18 Feb 2026 12:05:42 +0100 Subject: [PATCH 09/13] [FIX] model_generic.mustache to_str() --- .../resources/python/model_anyof.mustache | 22 +++++++++++++++++++ .../resources/python/model_generic.mustache | 10 ++++----- .../resources/python/model_oneof.mustache | 22 +++++++++++++++++++ .../openapi_client/models/bird.py | 10 ++++----- .../openapi_client/models/category.py | 10 ++++----- .../openapi_client/models/data_query.py | 10 ++++----- .../openapi_client/models/default_value.py | 10 ++++----- .../models/number_properties_only.py | 10 ++++----- .../openapi_client/models/pet.py | 10 ++++----- .../openapi_client/models/query.py | 10 ++++----- .../openapi_client/models/tag.py | 10 ++++----- ...st_form_object_multipart_request_marker.py | 10 ++++----- ...ue_object_all_of_query_object_parameter.py | 10 ++++----- ...rue_array_string_query_object_parameter.py | 10 ++++----- .../python/openapi_client/models/bird.py | 10 ++++----- .../python/openapi_client/models/category.py | 10 ++++----- .../openapi_client/models/data_query.py | 10 ++++----- .../openapi_client/models/default_value.py | 10 ++++----- .../models/number_properties_only.py | 10 ++++----- .../python/openapi_client/models/pet.py | 10 ++++----- .../python/openapi_client/models/query.py | 10 ++++----- .../python/openapi_client/models/tag.py | 10 ++++----- ...st_form_object_multipart_request_marker.py | 10 ++++----- ...ue_object_all_of_query_object_parameter.py | 10 ++++----- ...rue_array_string_query_object_parameter.py | 10 ++++----- .../models/additional_properties_any_type.py | 10 ++++----- .../models/additional_properties_class.py | 10 ++++----- .../models/additional_properties_object.py | 10 ++++----- ...tional_properties_with_description_only.py | 10 ++++----- .../petstore_api/models/all_of_super_model.py | 10 ++++----- .../models/all_of_with_single_ref.py | 10 ++++----- .../petstore_api/models/animal.py | 10 ++++----- .../petstore_api/models/any_of_color.py | 22 +++++++++++++++++++ .../petstore_api/models/any_of_pig.py | 22 +++++++++++++++++++ .../models/array_of_array_of_model.py | 10 ++++----- .../models/array_of_array_of_number_only.py | 10 ++++----- .../models/array_of_number_only.py | 10 ++++----- .../petstore_api/models/array_test.py | 10 ++++----- .../petstore_api/models/base_discriminator.py | 10 ++++----- .../petstore_api/models/basque_pig.py | 10 ++++----- .../petstore_api/models/bathing.py | 10 ++++----- .../petstore_api/models/capitalization.py | 10 ++++----- .../python-aiohttp/petstore_api/models/cat.py | 10 ++++----- .../petstore_api/models/category.py | 10 ++++----- .../models/circular_all_of_ref.py | 10 ++++----- .../models/circular_reference_model.py | 10 ++++----- .../petstore_api/models/class_model.py | 10 ++++----- .../petstore_api/models/client.py | 10 ++++----- .../petstore_api/models/color.py | 22 +++++++++++++++++++ .../petstore_api/models/creature.py | 10 ++++----- .../petstore_api/models/creature_info.py | 10 ++++----- .../petstore_api/models/danish_pig.py | 10 ++++----- .../petstore_api/models/deprecated_object.py | 10 ++++----- .../models/discriminator_all_of_sub.py | 10 ++++----- .../models/discriminator_all_of_super.py | 10 ++++----- .../python-aiohttp/petstore_api/models/dog.py | 10 ++++----- .../petstore_api/models/dummy_model.py | 10 ++++----- .../petstore_api/models/enum_arrays.py | 10 ++++----- .../models/enum_ref_with_default_value.py | 10 ++++----- .../petstore_api/models/enum_test.py | 10 ++++----- .../petstore_api/models/feeding.py | 10 ++++----- .../petstore_api/models/file.py | 10 ++++----- .../models/file_schema_test_class.py | 10 ++++----- .../petstore_api/models/first_ref.py | 10 ++++----- .../python-aiohttp/petstore_api/models/foo.py | 10 ++++----- .../models/foo_get_default_response.py | 10 ++++----- .../petstore_api/models/format_test.py | 10 ++++----- .../petstore_api/models/has_only_read_only.py | 10 ++++----- .../models/health_check_result.py | 10 ++++----- .../petstore_api/models/hunting_dog.py | 10 ++++----- .../petstore_api/models/info.py | 10 ++++----- .../models/inner_dict_with_property.py | 10 ++++----- .../petstore_api/models/input_all_of.py | 10 ++++----- .../petstore_api/models/int_or_string.py | 22 +++++++++++++++++++ .../petstore_api/models/list_class.py | 10 ++++----- .../models/map_of_array_of_model.py | 10 ++++----- .../petstore_api/models/map_test.py | 10 ++++----- ...perties_and_additional_properties_class.py | 10 ++++----- .../petstore_api/models/model200_response.py | 10 ++++----- .../petstore_api/models/model_api_response.py | 10 ++++----- .../petstore_api/models/model_field.py | 10 ++++----- .../petstore_api/models/model_return.py | 10 ++++----- .../petstore_api/models/multi_arrays.py | 10 ++++----- .../petstore_api/models/name.py | 10 ++++----- .../petstore_api/models/nullable_class.py | 10 ++++----- .../petstore_api/models/nullable_property.py | 10 ++++----- .../petstore_api/models/number_only.py | 10 ++++----- .../object_to_test_additional_properties.py | 10 ++++----- .../models/object_with_deprecated_fields.py | 10 ++++----- .../petstore_api/models/order.py | 10 ++++----- .../petstore_api/models/outer_composite.py | 10 ++++----- .../models/outer_object_with_enum_property.py | 10 ++++----- .../petstore_api/models/parent.py | 10 ++++----- .../models/parent_with_optional_dict.py | 10 ++++----- .../python-aiohttp/petstore_api/models/pet.py | 10 ++++----- .../python-aiohttp/petstore_api/models/pig.py | 22 +++++++++++++++++++ .../petstore_api/models/pony_sizes.py | 10 ++++----- .../petstore_api/models/poop_cleaning.py | 10 ++++----- .../petstore_api/models/primitive_string.py | 10 ++++----- .../petstore_api/models/property_map.py | 10 ++++----- .../models/property_name_collision.py | 10 ++++----- .../petstore_api/models/read_only_first.py | 10 ++++----- .../models/second_circular_all_of_ref.py | 10 ++++----- .../petstore_api/models/second_ref.py | 10 ++++----- .../models/self_reference_model.py | 10 ++++----- .../petstore_api/models/special_model_name.py | 10 ++++----- .../petstore_api/models/special_name.py | 10 ++++----- .../python-aiohttp/petstore_api/models/tag.py | 10 ++++----- .../petstore_api/models/task.py | 10 ++++----- .../petstore_api/models/task_activity.py | 22 +++++++++++++++++++ ..._error_responses_with_model400_response.py | 10 ++++----- ..._error_responses_with_model404_response.py | 10 ++++----- ..._freeform_additional_properties_request.py | 10 ++++----- .../models/test_model_with_enum_default.py | 10 ++++----- ...t_for_multipart_requests_request_marker.py | 10 ++++----- .../petstore_api/models/tiger.py | 10 ++++----- ...t_with_additional_model_list_properties.py | 10 ++++----- ..._with_additional_string_list_properties.py | 10 ++++----- ...th_additional_properties_request_object.py | 10 ++++----- .../petstore_api/models/user.py | 10 ++++----- .../petstore_api/models/with_nested_one_of.py | 10 ++++----- .../models/additional_properties_any_type.py | 10 ++++----- .../models/additional_properties_class.py | 10 ++++----- .../models/additional_properties_object.py | 10 ++++----- ...tional_properties_with_description_only.py | 10 ++++----- .../petstore_api/models/all_of_super_model.py | 10 ++++----- .../models/all_of_with_single_ref.py | 10 ++++----- .../petstore_api/models/animal.py | 10 ++++----- .../petstore_api/models/any_of_color.py | 22 +++++++++++++++++++ .../petstore_api/models/any_of_pig.py | 22 +++++++++++++++++++ .../models/array_of_array_of_model.py | 10 ++++----- .../models/array_of_array_of_number_only.py | 10 ++++----- .../models/array_of_number_only.py | 10 ++++----- .../petstore_api/models/array_test.py | 10 ++++----- .../petstore_api/models/base_discriminator.py | 10 ++++----- .../petstore_api/models/basque_pig.py | 10 ++++----- .../petstore_api/models/bathing.py | 10 ++++----- .../petstore_api/models/capitalization.py | 10 ++++----- .../python-httpx/petstore_api/models/cat.py | 10 ++++----- .../petstore_api/models/category.py | 10 ++++----- .../models/circular_all_of_ref.py | 10 ++++----- .../models/circular_reference_model.py | 10 ++++----- .../petstore_api/models/class_model.py | 10 ++++----- .../petstore_api/models/client.py | 10 ++++----- .../python-httpx/petstore_api/models/color.py | 22 +++++++++++++++++++ .../petstore_api/models/creature.py | 10 ++++----- .../petstore_api/models/creature_info.py | 10 ++++----- .../petstore_api/models/danish_pig.py | 10 ++++----- .../petstore_api/models/deprecated_object.py | 10 ++++----- .../models/discriminator_all_of_sub.py | 10 ++++----- .../models/discriminator_all_of_super.py | 10 ++++----- .../python-httpx/petstore_api/models/dog.py | 10 ++++----- .../petstore_api/models/dummy_model.py | 10 ++++----- .../petstore_api/models/enum_arrays.py | 10 ++++----- .../models/enum_ref_with_default_value.py | 10 ++++----- .../petstore_api/models/enum_test.py | 10 ++++----- .../petstore_api/models/feeding.py | 10 ++++----- .../python-httpx/petstore_api/models/file.py | 10 ++++----- .../models/file_schema_test_class.py | 10 ++++----- .../petstore_api/models/first_ref.py | 10 ++++----- .../python-httpx/petstore_api/models/foo.py | 10 ++++----- .../models/foo_get_default_response.py | 10 ++++----- .../petstore_api/models/format_test.py | 10 ++++----- .../petstore_api/models/has_only_read_only.py | 10 ++++----- .../models/health_check_result.py | 10 ++++----- .../petstore_api/models/hunting_dog.py | 10 ++++----- .../python-httpx/petstore_api/models/info.py | 10 ++++----- .../models/inner_dict_with_property.py | 10 ++++----- .../petstore_api/models/input_all_of.py | 10 ++++----- .../petstore_api/models/int_or_string.py | 22 +++++++++++++++++++ .../petstore_api/models/list_class.py | 10 ++++----- .../models/map_of_array_of_model.py | 10 ++++----- .../petstore_api/models/map_test.py | 10 ++++----- ...perties_and_additional_properties_class.py | 10 ++++----- .../petstore_api/models/model200_response.py | 10 ++++----- .../petstore_api/models/model_api_response.py | 10 ++++----- .../petstore_api/models/model_field.py | 10 ++++----- .../petstore_api/models/model_return.py | 10 ++++----- .../petstore_api/models/multi_arrays.py | 10 ++++----- .../python-httpx/petstore_api/models/name.py | 10 ++++----- .../petstore_api/models/nullable_class.py | 10 ++++----- .../petstore_api/models/nullable_property.py | 10 ++++----- .../petstore_api/models/number_only.py | 10 ++++----- .../object_to_test_additional_properties.py | 10 ++++----- .../models/object_with_deprecated_fields.py | 10 ++++----- .../python-httpx/petstore_api/models/order.py | 10 ++++----- .../petstore_api/models/outer_composite.py | 10 ++++----- .../models/outer_object_with_enum_property.py | 10 ++++----- .../petstore_api/models/parent.py | 10 ++++----- .../models/parent_with_optional_dict.py | 10 ++++----- .../python-httpx/petstore_api/models/pet.py | 10 ++++----- .../python-httpx/petstore_api/models/pig.py | 22 +++++++++++++++++++ .../petstore_api/models/pony_sizes.py | 10 ++++----- .../petstore_api/models/poop_cleaning.py | 10 ++++----- .../petstore_api/models/primitive_string.py | 10 ++++----- .../petstore_api/models/property_map.py | 10 ++++----- .../models/property_name_collision.py | 10 ++++----- .../petstore_api/models/read_only_first.py | 10 ++++----- .../models/second_circular_all_of_ref.py | 10 ++++----- .../petstore_api/models/second_ref.py | 10 ++++----- .../models/self_reference_model.py | 10 ++++----- .../petstore_api/models/special_model_name.py | 10 ++++----- .../petstore_api/models/special_name.py | 10 ++++----- .../python-httpx/petstore_api/models/tag.py | 10 ++++----- .../python-httpx/petstore_api/models/task.py | 10 ++++----- .../petstore_api/models/task_activity.py | 22 +++++++++++++++++++ ..._error_responses_with_model400_response.py | 10 ++++----- ..._error_responses_with_model404_response.py | 10 ++++----- ..._freeform_additional_properties_request.py | 10 ++++----- .../models/test_model_with_enum_default.py | 10 ++++----- ...t_for_multipart_requests_request_marker.py | 10 ++++----- .../python-httpx/petstore_api/models/tiger.py | 10 ++++----- ...t_with_additional_model_list_properties.py | 10 ++++----- ..._with_additional_string_list_properties.py | 10 ++++----- ...th_additional_properties_request_object.py | 10 ++++----- .../python-httpx/petstore_api/models/user.py | 10 ++++----- .../petstore_api/models/with_nested_one_of.py | 10 ++++----- .../models/additional_properties_any_type.py | 10 ++++----- .../models/additional_properties_class.py | 10 ++++----- .../models/additional_properties_object.py | 10 ++++----- ...tional_properties_with_description_only.py | 10 ++++----- .../petstore_api/models/all_of_super_model.py | 10 ++++----- .../models/all_of_with_single_ref.py | 10 ++++----- .../petstore_api/models/animal.py | 10 ++++----- .../petstore_api/models/any_of_color.py | 22 +++++++++++++++++++ .../petstore_api/models/any_of_pig.py | 22 +++++++++++++++++++ .../models/array_of_array_of_model.py | 10 ++++----- .../models/array_of_array_of_number_only.py | 10 ++++----- .../models/array_of_number_only.py | 10 ++++----- .../petstore_api/models/array_test.py | 10 ++++----- .../petstore_api/models/base_discriminator.py | 10 ++++----- .../petstore_api/models/basque_pig.py | 10 ++++----- .../petstore_api/models/bathing.py | 10 ++++----- .../petstore_api/models/capitalization.py | 10 ++++----- .../petstore_api/models/cat.py | 10 ++++----- .../petstore_api/models/category.py | 10 ++++----- .../models/circular_all_of_ref.py | 10 ++++----- .../models/circular_reference_model.py | 10 ++++----- .../petstore_api/models/class_model.py | 10 ++++----- .../petstore_api/models/client.py | 10 ++++----- .../petstore_api/models/color.py | 22 +++++++++++++++++++ .../petstore_api/models/creature.py | 10 ++++----- .../petstore_api/models/creature_info.py | 10 ++++----- .../petstore_api/models/danish_pig.py | 10 ++++----- .../petstore_api/models/deprecated_object.py | 10 ++++----- .../models/discriminator_all_of_sub.py | 10 ++++----- .../models/discriminator_all_of_super.py | 10 ++++----- .../petstore_api/models/dog.py | 10 ++++----- .../petstore_api/models/dummy_model.py | 10 ++++----- .../petstore_api/models/enum_arrays.py | 10 ++++----- .../models/enum_ref_with_default_value.py | 10 ++++----- .../petstore_api/models/enum_test.py | 10 ++++----- .../petstore_api/models/feeding.py | 10 ++++----- .../petstore_api/models/file.py | 10 ++++----- .../models/file_schema_test_class.py | 10 ++++----- .../petstore_api/models/first_ref.py | 10 ++++----- .../petstore_api/models/foo.py | 10 ++++----- .../models/foo_get_default_response.py | 10 ++++----- .../petstore_api/models/format_test.py | 10 ++++----- .../petstore_api/models/has_only_read_only.py | 10 ++++----- .../models/health_check_result.py | 10 ++++----- .../petstore_api/models/hunting_dog.py | 10 ++++----- .../petstore_api/models/info.py | 10 ++++----- .../models/inner_dict_with_property.py | 10 ++++----- .../petstore_api/models/input_all_of.py | 10 ++++----- .../petstore_api/models/int_or_string.py | 22 +++++++++++++++++++ .../petstore_api/models/list_class.py | 10 ++++----- .../models/map_of_array_of_model.py | 10 ++++----- .../petstore_api/models/map_test.py | 10 ++++----- ...perties_and_additional_properties_class.py | 10 ++++----- .../petstore_api/models/model200_response.py | 10 ++++----- .../petstore_api/models/model_api_response.py | 10 ++++----- .../petstore_api/models/model_field.py | 10 ++++----- .../petstore_api/models/model_return.py | 10 ++++----- .../petstore_api/models/multi_arrays.py | 10 ++++----- .../petstore_api/models/name.py | 10 ++++----- .../petstore_api/models/nullable_class.py | 10 ++++----- .../petstore_api/models/nullable_property.py | 10 ++++----- .../petstore_api/models/number_only.py | 10 ++++----- .../object_to_test_additional_properties.py | 10 ++++----- .../models/object_with_deprecated_fields.py | 10 ++++----- .../petstore_api/models/one_of_enum_string.py | 22 +++++++++++++++++++ .../petstore_api/models/order.py | 10 ++++----- .../petstore_api/models/outer_composite.py | 10 ++++----- .../models/outer_object_with_enum_property.py | 10 ++++----- .../petstore_api/models/parent.py | 10 ++++----- .../models/parent_with_optional_dict.py | 10 ++++----- .../petstore_api/models/pet.py | 10 ++++----- .../petstore_api/models/pig.py | 22 +++++++++++++++++++ .../petstore_api/models/pony_sizes.py | 10 ++++----- .../petstore_api/models/poop_cleaning.py | 10 ++++----- .../petstore_api/models/primitive_string.py | 10 ++++----- .../petstore_api/models/property_map.py | 10 ++++----- .../models/property_name_collision.py | 10 ++++----- .../petstore_api/models/read_only_first.py | 10 ++++----- .../models/second_circular_all_of_ref.py | 10 ++++----- .../petstore_api/models/second_ref.py | 10 ++++----- .../models/self_reference_model.py | 10 ++++----- .../petstore_api/models/special_model_name.py | 10 ++++----- .../petstore_api/models/special_name.py | 10 ++++----- .../petstore_api/models/tag.py | 10 ++++----- .../petstore_api/models/task.py | 10 ++++----- .../petstore_api/models/task_activity.py | 22 +++++++++++++++++++ ..._error_responses_with_model400_response.py | 10 ++++----- ..._error_responses_with_model404_response.py | 10 ++++----- ..._freeform_additional_properties_request.py | 10 ++++----- .../models/test_model_with_enum_default.py | 10 ++++----- ...t_for_multipart_requests_request_marker.py | 10 ++++----- .../petstore_api/models/tiger.py | 10 ++++----- ...t_with_additional_model_list_properties.py | 10 ++++----- ..._with_additional_string_list_properties.py | 10 ++++----- ...th_additional_properties_request_object.py | 10 ++++----- .../petstore_api/models/user.py | 10 ++++----- .../petstore_api/models/with_nested_one_of.py | 10 ++++----- .../models/additional_properties_any_type.py | 10 ++++----- .../models/additional_properties_class.py | 10 ++++----- .../models/additional_properties_object.py | 10 ++++----- ...tional_properties_with_description_only.py | 10 ++++----- .../petstore_api/models/all_of_super_model.py | 10 ++++----- .../models/all_of_with_single_ref.py | 10 ++++----- .../python/petstore_api/models/animal.py | 10 ++++----- .../petstore_api/models/any_of_color.py | 22 +++++++++++++++++++ .../python/petstore_api/models/any_of_pig.py | 22 +++++++++++++++++++ .../models/array_of_array_of_model.py | 10 ++++----- .../models/array_of_array_of_number_only.py | 10 ++++----- .../models/array_of_number_only.py | 10 ++++----- .../python/petstore_api/models/array_test.py | 10 ++++----- .../petstore_api/models/base_discriminator.py | 10 ++++----- .../python/petstore_api/models/basque_pig.py | 10 ++++----- .../python/petstore_api/models/bathing.py | 10 ++++----- .../petstore_api/models/capitalization.py | 10 ++++----- .../python/petstore_api/models/cat.py | 10 ++++----- .../python/petstore_api/models/category.py | 10 ++++----- .../models/circular_all_of_ref.py | 10 ++++----- .../models/circular_reference_model.py | 10 ++++----- .../python/petstore_api/models/class_model.py | 10 ++++----- .../python/petstore_api/models/client.py | 10 ++++----- .../python/petstore_api/models/color.py | 22 +++++++++++++++++++ .../python/petstore_api/models/creature.py | 10 ++++----- .../petstore_api/models/creature_info.py | 10 ++++----- .../python/petstore_api/models/danish_pig.py | 10 ++++----- .../petstore_api/models/deprecated_object.py | 10 ++++----- .../models/discriminator_all_of_sub.py | 10 ++++----- .../models/discriminator_all_of_super.py | 10 ++++----- .../python/petstore_api/models/dog.py | 10 ++++----- .../python/petstore_api/models/dummy_model.py | 10 ++++----- .../python/petstore_api/models/enum_arrays.py | 10 ++++----- .../models/enum_ref_with_default_value.py | 10 ++++----- .../python/petstore_api/models/enum_test.py | 10 ++++----- .../python/petstore_api/models/feeding.py | 10 ++++----- .../python/petstore_api/models/file.py | 10 ++++----- .../models/file_schema_test_class.py | 10 ++++----- .../python/petstore_api/models/first_ref.py | 10 ++++----- .../python/petstore_api/models/foo.py | 10 ++++----- .../models/foo_get_default_response.py | 10 ++++----- .../python/petstore_api/models/format_test.py | 10 ++++----- .../petstore_api/models/has_only_read_only.py | 10 ++++----- .../models/health_check_result.py | 10 ++++----- .../python/petstore_api/models/hunting_dog.py | 10 ++++----- .../python/petstore_api/models/info.py | 10 ++++----- .../models/inner_dict_with_property.py | 10 ++++----- .../petstore_api/models/input_all_of.py | 10 ++++----- .../petstore_api/models/int_or_string.py | 22 +++++++++++++++++++ .../python/petstore_api/models/list_class.py | 10 ++++----- .../models/map_of_array_of_model.py | 10 ++++----- .../python/petstore_api/models/map_test.py | 10 ++++----- ...perties_and_additional_properties_class.py | 10 ++++----- .../petstore_api/models/model200_response.py | 10 ++++----- .../petstore_api/models/model_api_response.py | 10 ++++----- .../python/petstore_api/models/model_field.py | 10 ++++----- .../petstore_api/models/model_return.py | 10 ++++----- .../petstore_api/models/multi_arrays.py | 10 ++++----- .../python/petstore_api/models/name.py | 10 ++++----- .../petstore_api/models/nullable_class.py | 10 ++++----- .../petstore_api/models/nullable_property.py | 10 ++++----- .../python/petstore_api/models/number_only.py | 10 ++++----- .../object_to_test_additional_properties.py | 10 ++++----- .../models/object_with_deprecated_fields.py | 10 ++++----- .../petstore_api/models/one_of_enum_string.py | 22 +++++++++++++++++++ .../python/petstore_api/models/order.py | 10 ++++----- .../petstore_api/models/outer_composite.py | 10 ++++----- .../models/outer_object_with_enum_property.py | 10 ++++----- .../python/petstore_api/models/parent.py | 10 ++++----- .../models/parent_with_optional_dict.py | 10 ++++----- .../python/petstore_api/models/pet.py | 10 ++++----- .../python/petstore_api/models/pig.py | 22 +++++++++++++++++++ .../python/petstore_api/models/pony_sizes.py | 10 ++++----- .../petstore_api/models/poop_cleaning.py | 10 ++++----- .../petstore_api/models/primitive_string.py | 10 ++++----- .../petstore_api/models/property_map.py | 10 ++++----- .../models/property_name_collision.py | 10 ++++----- .../petstore_api/models/read_only_first.py | 10 ++++----- .../models/second_circular_all_of_ref.py | 10 ++++----- .../python/petstore_api/models/second_ref.py | 10 ++++----- .../models/self_reference_model.py | 10 ++++----- .../petstore_api/models/special_model_name.py | 10 ++++----- .../petstore_api/models/special_name.py | 10 ++++----- .../python/petstore_api/models/tag.py | 10 ++++----- .../python/petstore_api/models/task.py | 10 ++++----- .../petstore_api/models/task_activity.py | 22 +++++++++++++++++++ ..._error_responses_with_model400_response.py | 10 ++++----- ..._error_responses_with_model404_response.py | 10 ++++----- ..._freeform_additional_properties_request.py | 10 ++++----- .../models/test_model_with_enum_default.py | 10 ++++----- ...t_for_multipart_requests_request_marker.py | 10 ++++----- .../python/petstore_api/models/tiger.py | 10 ++++----- ...t_with_additional_model_list_properties.py | 10 ++++----- ..._with_additional_string_list_properties.py | 10 ++++----- ...th_additional_properties_request_object.py | 10 ++++----- .../python/petstore_api/models/user.py | 10 ++++----- .../petstore_api/models/with_nested_one_of.py | 10 ++++----- 411 files changed, 2531 insertions(+), 1915 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index 2593a9ac378b..60763f2b24ef 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -35,6 +35,28 @@ class {{classname}}(RootModel[Union[{{#anyOf}}{{.}}{{^-last}}, {{/-last}}{{/anyO raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} {{{.}}} diff --git a/modules/openapi-generator/src/main/resources/python/model_generic.mustache b/modules/openapi-generator/src/main/resources/python/model_generic.mustache index 72c10fba004c..e9c83d0c1dd1 100644 --- a/modules/openapi-generator/src/main/resources/python/model_generic.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_generic.mustache @@ -166,17 +166,17 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) {{#vendorExtensions.x-py-postponed-model-imports.size}} diff --git a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache index ab97fda35dea..7cf093f7a80e 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -35,6 +35,28 @@ class {{classname}}(RootModel[Union[{{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/on raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + {{#vendorExtensions.x-py-postponed-model-imports.size}} {{#vendorExtensions.x-py-postponed-model-imports}} {{{.}}} diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py index ab504ea13788..61a709ecd827 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/bird.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py index b5d1feff8954..f5fba53c0249 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/category.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py index 469701d7adc1..7c35f11bde5d 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/data_query.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py index 3afdd3cf4086..b6367842fc7a 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/default_value.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py index 54924629f13c..6c0545753362 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/number_properties_only.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py index d1447ef248bf..95d3a9e95192 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/pet.py @@ -68,17 +68,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py index a9db31353813..408b2314f00a 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/query.py @@ -63,17 +63,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py index ec088768dc6e..6c0ee59f511c 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/tag.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py index 6fc587105874..598a94d57ba5 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_form_object_multipart_request_marker.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 52a77611a10f..601ea372cad4 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 688824243b4e..00048c50942d 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/bird.py b/samples/client/echo_api/python/openapi_client/models/bird.py index ab504ea13788..61a709ecd827 100644 --- a/samples/client/echo_api/python/openapi_client/models/bird.py +++ b/samples/client/echo_api/python/openapi_client/models/bird.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/category.py b/samples/client/echo_api/python/openapi_client/models/category.py index b5d1feff8954..f5fba53c0249 100644 --- a/samples/client/echo_api/python/openapi_client/models/category.py +++ b/samples/client/echo_api/python/openapi_client/models/category.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/data_query.py b/samples/client/echo_api/python/openapi_client/models/data_query.py index 469701d7adc1..7c35f11bde5d 100644 --- a/samples/client/echo_api/python/openapi_client/models/data_query.py +++ b/samples/client/echo_api/python/openapi_client/models/data_query.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/default_value.py b/samples/client/echo_api/python/openapi_client/models/default_value.py index 3afdd3cf4086..b6367842fc7a 100644 --- a/samples/client/echo_api/python/openapi_client/models/default_value.py +++ b/samples/client/echo_api/python/openapi_client/models/default_value.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py index 54924629f13c..6c0545753362 100644 --- a/samples/client/echo_api/python/openapi_client/models/number_properties_only.py +++ b/samples/client/echo_api/python/openapi_client/models/number_properties_only.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/pet.py b/samples/client/echo_api/python/openapi_client/models/pet.py index d1447ef248bf..95d3a9e95192 100644 --- a/samples/client/echo_api/python/openapi_client/models/pet.py +++ b/samples/client/echo_api/python/openapi_client/models/pet.py @@ -68,17 +68,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/query.py b/samples/client/echo_api/python/openapi_client/models/query.py index a9db31353813..408b2314f00a 100644 --- a/samples/client/echo_api/python/openapi_client/models/query.py +++ b/samples/client/echo_api/python/openapi_client/models/query.py @@ -63,17 +63,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/tag.py b/samples/client/echo_api/python/openapi_client/models/tag.py index ec088768dc6e..6c0ee59f511c 100644 --- a/samples/client/echo_api/python/openapi_client/models/tag.py +++ b/samples/client/echo_api/python/openapi_client/models/tag.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py index 6fc587105874..598a94d57ba5 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py +++ b/samples/client/echo_api/python/openapi_client/models/test_form_object_multipart_request_marker.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py index 52a77611a10f..601ea372cad4 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py index 688824243b4e..00048c50942d 100644 --- a/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py +++ b/samples/client/echo_api/python/openapi_client/models/test_query_style_form_explode_true_array_string_query_object_parameter.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py index bc200fb99195..60117040e669 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py index b07374ffccd7..6ba8728d9502 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_class.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py index 94c9c90a088b..4e07f7d2f972 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py index 1f589af3b288..54aa79b74ac8 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py index 0b30cd2e8be0..e53091d1a383 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_super_model.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py index 71025d084c28..1e262a871f71 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/all_of_with_single_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py index fe4451ba83d3..c38dc9dc3646 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/animal.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py index 970bd7582756..fbc45baaec11 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py index a90287e17b02..1a075fcaf2d1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py index 6fa4d4a454b0..56f6a584e3ed 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py index 028601c27645..6c11922b7bf3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_array_of_number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py index bae55244e51b..dbb83e66c1ef 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_of_number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py index 8488d796deeb..0c0e34a932be 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/array_test.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py index 25e061a0493c..09f97595c6ff 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/base_discriminator.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py index 80fbbc69f0ba..4831ea9e6492 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/basque_pig.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py index ea5d5fed0fad..c4a0f734b19d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/bathing.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py index d28295ae3750..c5b840970c40 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/capitalization.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py index bd1f68423276..bc531a937e05 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/cat.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py index 4509cf9404d8..ae890b3aac45 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/category.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py index 6cf2bba58527..68b3bed1b335 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_all_of_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py index 388aeb6934cb..e108d79be53b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/circular_reference_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py index 621e72a9bcba..4b45b99bb5ec 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/class_model.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py index 384583d040ea..ebd328785c66 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/client.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py index 608ec222a231..c37defbd0000 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py index 213596b2ac25..08829e9ca389 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py index 2ab71554ced0..0ebdf86cf129 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/creature_info.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py index f2c4f78ed091..b4b7d3ab2456 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/danish_pig.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py index 4f0467c1c95a..62f58bc34b6d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/deprecated_object.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py index 0844ee6a4927..382c389063a9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_sub.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py index 36aea7a9805f..93a47ee1a995 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/discriminator_all_of_super.py @@ -69,17 +69,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py index 3f54b5b2768a..020cc7100aae 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dog.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py index 1e4a8d9a6a08..1e17b7e5edc1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/dummy_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py index 2ab5d04d5471..1459196a8acd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_arrays.py @@ -75,17 +75,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py index 781f8b14d449..430d4898334e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_ref_with_default_value.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py index 3cb0baf0f32f..9b276c7fa51c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_test.py @@ -155,17 +155,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py index 47265928799b..8892bb51b8e7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/feeding.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py index 02bef49b7f62..876d27c32653 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py index c940688cf137..5c80a5d30f35 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/file_schema_test_class.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py index cf3dd91f5b20..ffc8d0f31a49 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/first_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py index 7c3d514c1475..79c85c1886a7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py index cc8fb33b1baf..d721655ef251 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/foo_get_default_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py index cacfdaab97eb..b014ac7fc203 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/format_test.py @@ -107,17 +107,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py index 6066f46682c6..3f767ca7bb4f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/has_only_read_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py index 6f829c83f0ad..88a4eb1cfdff 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/health_check_result.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py index cd2436271ec9..bb7118a4a2c5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/hunting_dog.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py index 1af076053369..ae9608e5db99 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/info.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py index ea4cde3995b8..9607f565f9a9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/inner_dict_with_property.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py index 44abab5b841d..2e200d3fc88b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/input_all_of.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py index b57c4c9d0f36..4f346924baa0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py index a6f8bfcd619b..57c3e5e60e8c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/list_class.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py index 2fd3f9b22d21..19ad96c4bd7a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_of_array_of_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py index 148b4b11e2a3..68c7af200a10 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/map_test.py @@ -64,17 +64,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py index 10295e10dbb4..e569ea3966fc 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py index 7f5963510c12..1c21fe7c207e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model200_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py index 7783a8200a82..0d3aa6c842b9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_api_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py index eabf59f93c8d..07b781f12c6c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_field.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py index a79d088d17da..61d61fa1e30d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/model_return.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py index db9b94cd8582..dc0a76560b28 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/multi_arrays.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py index 9af8ee448a6a..a4dec6b1b4a7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/name.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py index 78404ee41ec6..f8684b51f9a2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py @@ -61,17 +61,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py index 8f0e6a41984f..4e076ef0e436 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_property.py @@ -59,17 +59,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py index b6c02228c5e2..504b4e22fad5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py index 79c42917a8b8..42801db04898 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_to_test_additional_properties.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py index da291134461c..d469f6680529 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/object_with_deprecated_fields.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py index 7a3b7c57c7e7..c9c3e5bbee29 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/order.py @@ -66,17 +66,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py index f3adc7c3b8de..822dab063c0e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_composite.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py index 624e3331542e..984cfddf88eb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_object_with_enum_property.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py index 24a1886628ce..5e9fa604926b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py index 256b0df2a1dc..8c684194a183 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/parent_with_optional_dict.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py index ea13c5465e3b..b72b95d94822 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pet.py @@ -68,17 +68,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py index 4cc32f18c42d..ae990d4fe765 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py index b7bc4533ca78..14474dbdd5b5 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pony_sizes.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py index 8e6803afdcbb..2bf6f87d14d6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/poop_cleaning.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py index 809a7741366c..9f265ec63372 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/primitive_string.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py index 336223a9c4df..a1b3b0886094 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_map.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py index 4ac90edf7de2..13d9f5836fee 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/property_name_collision.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py index e629b9f1a094..b69f8a88ab5e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/read_only_first.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py index d2551e5802ac..6b4864e0f3e6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_circular_all_of_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py index 2507e2b84d4a..c74c7bb1f305 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/second_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py index 286894e0d559..d40afa7d9231 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/self_reference_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py index 13d5b24c52e0..5e127783fa6b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_model_name.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py index c54f89dfc489..4710deb8bf9c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_name.py @@ -63,17 +63,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py index f14a2afd272f..42dfb1c9588d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tag.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py index 158c3b99686b..25ce0822d99c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py index 15b92f1829bf..032a494548d0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py @@ -48,4 +48,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py index 4f377a4a4d36..3486657eeac7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py index 313c499def30..a8e9a506d8a6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py index d67bb5ef1f35..4e5f5f7bbba9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py index 6e09516062ae..00353a06e077 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_model_with_enum_default.py @@ -66,17 +66,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py index 2bb14ff8d58e..74dfb95f0fa3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py index 153a9f22de54..f4bd4e725d4d 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/tiger.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 9ca067dbfe25..06b3b929b2ad 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 72e05f458f96..b7507a12dcc0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py index 5bd3022c1efe..98b31a1f0fcd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py index 2868cbf027c6..1b926c1b8097 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/user.py @@ -54,17 +54,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py index 4aba1b28f89e..cadd8e8cc89e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/with_nested_one_of.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py index bc200fb99195..60117040e669 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_any_type.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py index b07374ffccd7..6ba8728d9502 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_class.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py index 94c9c90a088b..4e07f7d2f972 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py index 1f589af3b288..54aa79b74ac8 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/additional_properties_with_description_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py index 0b30cd2e8be0..e53091d1a383 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_super_model.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py index 71025d084c28..1e262a871f71 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/all_of_with_single_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py index fe4451ba83d3..c38dc9dc3646 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/animal.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py index 970bd7582756..fbc45baaec11 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py index a90287e17b02..1a075fcaf2d1 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py index 6fa4d4a454b0..56f6a584e3ed 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py index 028601c27645..6c11922b7bf3 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_array_of_number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py index bae55244e51b..dbb83e66c1ef 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_of_number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py index 8488d796deeb..0c0e34a932be 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/array_test.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py index 25e061a0493c..09f97595c6ff 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/base_discriminator.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py index 80fbbc69f0ba..4831ea9e6492 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/basque_pig.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py index ea5d5fed0fad..c4a0f734b19d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/bathing.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py index d28295ae3750..c5b840970c40 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/capitalization.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py index bd1f68423276..bc531a937e05 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/cat.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py index 4509cf9404d8..ae890b3aac45 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/category.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py index 6cf2bba58527..68b3bed1b335 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_all_of_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py index 388aeb6934cb..e108d79be53b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/circular_reference_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py index 621e72a9bcba..4b45b99bb5ec 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/class_model.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py index 384583d040ea..ebd328785c66 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/client.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py index 608ec222a231..c37defbd0000 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py index 213596b2ac25..08829e9ca389 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py index 2ab71554ced0..0ebdf86cf129 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/creature_info.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py index f2c4f78ed091..b4b7d3ab2456 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/danish_pig.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py index 4f0467c1c95a..62f58bc34b6d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/deprecated_object.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py index 0844ee6a4927..382c389063a9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_sub.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py index 36aea7a9805f..93a47ee1a995 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/discriminator_all_of_super.py @@ -69,17 +69,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py index 3f54b5b2768a..020cc7100aae 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dog.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py index 1e4a8d9a6a08..1e17b7e5edc1 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/dummy_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py index 2ab5d04d5471..1459196a8acd 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_arrays.py @@ -75,17 +75,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py index 781f8b14d449..430d4898334e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_ref_with_default_value.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py index 3cb0baf0f32f..9b276c7fa51c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/enum_test.py @@ -155,17 +155,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py index 47265928799b..8892bb51b8e7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/feeding.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py index 02bef49b7f62..876d27c32653 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py index c940688cf137..5c80a5d30f35 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/file_schema_test_class.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py index cf3dd91f5b20..ffc8d0f31a49 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/first_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py index 7c3d514c1475..79c85c1886a7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py index cc8fb33b1baf..d721655ef251 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/foo_get_default_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py index cacfdaab97eb..b014ac7fc203 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/format_test.py @@ -107,17 +107,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py index 6066f46682c6..3f767ca7bb4f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/has_only_read_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py index 6f829c83f0ad..88a4eb1cfdff 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/health_check_result.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py index cd2436271ec9..bb7118a4a2c5 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/hunting_dog.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py index 1af076053369..ae9608e5db99 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/info.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py index ea4cde3995b8..9607f565f9a9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/inner_dict_with_property.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py index 44abab5b841d..2e200d3fc88b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/input_all_of.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py index b57c4c9d0f36..4f346924baa0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py index a6f8bfcd619b..57c3e5e60e8c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/list_class.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py index 2fd3f9b22d21..19ad96c4bd7a 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_of_array_of_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py index 148b4b11e2a3..68c7af200a10 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/map_test.py @@ -64,17 +64,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py index 10295e10dbb4..e569ea3966fc 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py index 7f5963510c12..1c21fe7c207e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model200_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py index 7783a8200a82..0d3aa6c842b9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_api_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py index eabf59f93c8d..07b781f12c6c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_field.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py index a79d088d17da..61d61fa1e30d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/model_return.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py index db9b94cd8582..dc0a76560b28 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/multi_arrays.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py index 9af8ee448a6a..a4dec6b1b4a7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/name.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py index 78404ee41ec6..f8684b51f9a2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_class.py @@ -61,17 +61,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py index 8f0e6a41984f..4e076ef0e436 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/nullable_property.py @@ -59,17 +59,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py index b6c02228c5e2..504b4e22fad5 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/number_only.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py index 79c42917a8b8..42801db04898 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_to_test_additional_properties.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py index da291134461c..d469f6680529 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/object_with_deprecated_fields.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py index 7a3b7c57c7e7..c9c3e5bbee29 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/order.py @@ -66,17 +66,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py index f3adc7c3b8de..822dab063c0e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_composite.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py index 624e3331542e..984cfddf88eb 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/outer_object_with_enum_property.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py index 24a1886628ce..5e9fa604926b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py index 256b0df2a1dc..8c684194a183 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/parent_with_optional_dict.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py index ea13c5465e3b..b72b95d94822 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pet.py @@ -68,17 +68,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py index 4cc32f18c42d..ae990d4fe765 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py index b7bc4533ca78..14474dbdd5b5 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pony_sizes.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py index 8e6803afdcbb..2bf6f87d14d6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/poop_cleaning.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py index 809a7741366c..9f265ec63372 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/primitive_string.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py index 336223a9c4df..a1b3b0886094 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_map.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py index 4ac90edf7de2..13d9f5836fee 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/property_name_collision.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py index e629b9f1a094..b69f8a88ab5e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/read_only_first.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py index d2551e5802ac..6b4864e0f3e6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_circular_all_of_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py index 2507e2b84d4a..c74c7bb1f305 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/second_ref.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py index 286894e0d559..d40afa7d9231 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/self_reference_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py index 13d5b24c52e0..5e127783fa6b 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_model_name.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py index c54f89dfc489..4710deb8bf9c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/special_name.py @@ -63,17 +63,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py index f14a2afd272f..42dfb1c9588d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tag.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py index 158c3b99686b..25ce0822d99c 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py index 15b92f1829bf..032a494548d0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py @@ -48,4 +48,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py index 4f377a4a4d36..3486657eeac7 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model400_response.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py index 313c499def30..a8e9a506d8a6 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_error_responses_with_model404_response.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py index d67bb5ef1f35..4e5f5f7bbba9 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py index 6e09516062ae..00353a06e077 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_model_with_enum_default.py @@ -66,17 +66,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py index 2bb14ff8d58e..74dfb95f0fa3 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py index 153a9f22de54..f4bd4e725d4d 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/tiger.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 9ca067dbfe25..06b3b929b2ad 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index 72e05f458f96..b7507a12dcc0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py index 5bd3022c1efe..98b31a1f0fcd 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -47,17 +47,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py index 2868cbf027c6..1b926c1b8097 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/user.py @@ -54,17 +54,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py index 4aba1b28f89e..cadd8e8cc89e 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/with_nested_one_of.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py index bc200fb99195..60117040e669 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_any_type.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py index 41db98c3e62f..937b2af13cad 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_class.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py index 94c9c90a088b..4e07f7d2f972 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py index 1f589af3b288..54aa79b74ac8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/additional_properties_with_description_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py index 401413233f21..4e12dfd9c941 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_super_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py index 5dfadd977245..04b1b1a1ab20 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/all_of_with_single_ref.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py index 28b17142a816..4e627faa05d9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/animal.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py index 970bd7582756..fbc45baaec11 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py index a90287e17b02..1a075fcaf2d1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py index 9505ce0b6c35..4f6d5d71cab3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py index 7776dfd14a7a..2eb5ac7f38f2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_array_of_number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py index c6d99aec508e..e7326e131225 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_of_number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py index 9a52407bb57e..82c8b4b470c6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/array_test.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py index 6770a2e587a4..069983ab8ad8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/base_discriminator.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py index 3166836059f5..34f9a1c49fcf 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/basque_pig.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py index c0288ed8f985..a1e7d1f8d912 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/bathing.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py index 6865ed963c9a..07b05e2d9ecf 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/capitalization.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py index 8c81c11b1b29..e0b2668865c4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/cat.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py index 614f25486a89..fcb04a854946 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/category.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py index e1bcb36e7e68..4a8047a806fc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_all_of_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py index 616bd5a7dd49..1d032abaa0c9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/circular_reference_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py index 264a218d6dd8..83d4aacc9758 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/class_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py index aa893e0d6104..0adb4069462e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/client.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py index 608ec222a231..c37defbd0000 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py index a2698a0a3164..497b8b163c24 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py index 8b607b1d2065..23ba3d17d832 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/creature_info.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py index afd589a99cfc..d81e8dff4ada 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/danish_pig.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py index 1717b330ec9e..9fd3f467c438 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/deprecated_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py index b2bf6bef8628..edb56f79b6d4 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_sub.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py index f9839d6f278f..97873195d93e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/discriminator_all_of_super.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py index 496d3f95f3ba..95453f75bed0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dog.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py index b99f6a904ce7..d86438c94af2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/dummy_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py index e56c6b336ea0..b90294e8cfe9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_arrays.py @@ -76,17 +76,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py index 2ad94c2c5de1..29b0ba0db4d6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_ref_with_default_value.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py index b508224d8b85..e604bce099b5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/enum_test.py @@ -156,17 +156,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py index ca42b4335639..89f3cdeec99a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/feeding.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py index 554374cfbe07..7265634fa3f3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py index d74d8dbae883..6944bd5877b6 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/file_schema_test_class.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py index fdf46e6260a9..babca8086895 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/first_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py index e77a2905c9f4..7a4bba08554a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py index b0db656eacfa..6a80719bb6e2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/foo_get_default_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py index 759262062e78..d8991d1942e7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/format_test.py @@ -108,17 +108,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py index c92fae193e56..2598173265d5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/has_only_read_only.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py index d062a5dfe853..635e7262f71e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/health_check_result.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py index 5e743ec84873..821d88c161f8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/hunting_dog.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py index 2771d60c2318..354224675139 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/info.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py index 9dcc377719e8..da6aa3979c76 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/inner_dict_with_property.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py index 60c833c81dcb..885a1b0b2169 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/input_all_of.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py index b57c4c9d0f36..4f346924baa0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py index c0c5fc4dae85..9c7a35689379 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/list_class.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py index 5e7a0bbfff9a..49aac0619cc1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_of_array_of_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py index 5b46fae4b015..eacfcffee87c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/map_test.py @@ -65,17 +65,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py index e7a6eb1c4604..7432110dec68 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py index ae0d0de0a380..4c6185c0bad8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model200_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py index f27857d233e2..ca86a7522db3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_api_response.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py index 672d5a2c1bab..26d71808c4cd 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_field.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py index affff9bc82a2..1fec4e618fda 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/model_return.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py index f4429792f542..11b1917671c1 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/multi_arrays.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py index 7392bcd94a96..82b1e064276e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/name.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py index 836632f92186..cc2bc471fca5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_class.py @@ -61,17 +61,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py index a2100a9d605c..9755c589027b 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/nullable_property.py @@ -60,17 +60,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py index 8015d2627315..18f1aea385ac 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py index a0b501f4510e..e3f81ad21526 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_to_test_additional_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py index 607178e61b3e..b92b0fc17dfe 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/object_with_deprecated_fields.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py index e2b2780beece..f4026d2a3f11 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py index bb5cf7cebd8b..92c2c1a3b7bf 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/order.py @@ -67,17 +67,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py index f3c5a1d1a290..114d3b7d45af 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_composite.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py index 98d966c63f88..904a3c679e19 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/outer_object_with_enum_property.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py index 67019aee1760..f02f0bda2fda 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py index 595d04b48cac..84ba2d1cb181 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/parent_with_optional_dict.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py index d10aa6bea0b3..c1997ebaec4c 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pet.py @@ -69,17 +69,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py index 4cc32f18c42d..ae990d4fe765 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py index 8330edb586e5..c559e6ee94f8 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pony_sizes.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py index 6404380de0bf..f5dc8336d0c2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/poop_cleaning.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py index 1dd55054ae68..66ca2d6acad5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/primitive_string.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py index ff945938c081..c9cb24b55232 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_map.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py index 17e3f07aeca9..49e6b8a39dbe 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/property_name_collision.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py index 696299173423..dcd9dc77b1d5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/read_only_first.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py index 7c460b2215df..c98976b4c435 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_circular_all_of_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py index d034d43bf66f..c56c670b5f3f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/second_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py index bf9197fce99f..8e4b63a8f56e 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/self_reference_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py index e75daa66036b..9485b0d164c5 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_model_name.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py index cb154e1ce529..9dda4787d27a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/special_name.py @@ -64,17 +64,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py index e5c4b57a1731..8a1e5d4d28b7 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tag.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py index 68ad30765acc..46581e55fb5a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py index 15b92f1829bf..032a494548d0 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py @@ -48,4 +48,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py index 4039342bc999..39184fe47503 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model400_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py index 93d9932f5b99..9c9d75d6c262 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_error_responses_with_model404_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py index d67bb5ef1f35..4e5f5f7bbba9 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py index 36ecd8a5abbb..3ec907de4321 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_model_with_enum_default.py @@ -67,17 +67,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py index 427a35ab86d8..43a97e47d598 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py index 897f0f0b897f..e2ba57da3381 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/tiger.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 5f8e42159a24..1b21583f30dd 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index c4e874f931ca..b7def9bdb496 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py index fefa4c26d8f9..e734f29371cb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py index a65ce66ddb99..261ba3ebe4c2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/user.py @@ -55,17 +55,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py index d1d79b8f0b04..8a2efae47855 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/with_nested_one_of.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py index bc200fb99195..60117040e669 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py index 41db98c3e62f..937b2af13cad 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_class.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py index 94c9c90a088b..4e07f7d2f972 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py index 1f589af3b288..54aa79b74ac8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py index 401413233f21..4e12dfd9c941 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_super_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py index 5dfadd977245..04b1b1a1ab20 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/all_of_with_single_ref.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py index 28b17142a816..4e627faa05d9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/animal.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/animal.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py index 970bd7582756..fbc45baaec11 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py index a90287e17b02..1a075fcaf2d1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py index 9505ce0b6c35..4f6d5d71cab3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py index 7776dfd14a7a..2eb5ac7f38f2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_array_of_number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py index c6d99aec508e..e7326e131225 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_of_number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py index 9a52407bb57e..82c8b4b470c6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/array_test.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py index 6770a2e587a4..069983ab8ad8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/base_discriminator.py @@ -71,17 +71,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py index 3166836059f5..34f9a1c49fcf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/basque_pig.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py index c0288ed8f985..a1e7d1f8d912 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/bathing.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py index 6865ed963c9a..07b05e2d9ecf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/capitalization.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py index 8c81c11b1b29..e0b2668865c4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/cat.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/cat.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/category.py b/samples/openapi3/client/petstore/python/petstore_api/models/category.py index 614f25486a89..fcb04a854946 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/category.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/category.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py index e1bcb36e7e68..4a8047a806fc 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_all_of_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.second_circular_all_of_ref import SecondCircularAllOfRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py index 616bd5a7dd49..1d032abaa0c9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/circular_reference_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.first_ref import FirstRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py index 264a218d6dd8..83d4aacc9758 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/class_model.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/client.py b/samples/openapi3/client/petstore/python/petstore_api/models/client.py index aa893e0d6104..0adb4069462e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/client.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/color.py b/samples/openapi3/client/petstore/python/petstore_api/models/color.py index 608ec222a231..c37defbd0000 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/color.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py index a2698a0a3164..497b8b163c24 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py index 8b607b1d2065..23ba3d17d832 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/creature_info.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py index afd589a99cfc..d81e8dff4ada 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/danish_pig.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py index 1717b330ec9e..9fd3f467c438 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/deprecated_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py index b2bf6bef8628..edb56f79b6d4 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_sub.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py index f9839d6f278f..97873195d93e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/discriminator_all_of_super.py @@ -70,17 +70,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py index 496d3f95f3ba..95453f75bed0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dog.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py index b99f6a904ce7..d86438c94af2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/dummy_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.self_reference_model import SelfReferenceModel diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py index e56c6b336ea0..b90294e8cfe9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_arrays.py @@ -76,17 +76,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py index 2ad94c2c5de1..29b0ba0db4d6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_ref_with_default_value.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py index b508224d8b85..e604bce099b5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_test.py @@ -156,17 +156,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py index ca42b4335639..89f3cdeec99a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/feeding.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file.py b/samples/openapi3/client/petstore/python/petstore_api/models/file.py index 554374cfbe07..7265634fa3f3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py index d74d8dbae883..6944bd5877b6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/file_schema_test_class.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py index fdf46e6260a9..babca8086895 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/first_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.second_ref import SecondRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py index e77a2905c9f4..7a4bba08554a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py index b0db656eacfa..6a80719bb6e2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/foo_get_default_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py index 759262062e78..d8991d1942e7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/format_test.py @@ -108,17 +108,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py index c92fae193e56..2598173265d5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/has_only_read_only.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py index d062a5dfe853..635e7262f71e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/health_check_result.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py index 5e743ec84873..821d88c161f8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/hunting_dog.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/info.py b/samples/openapi3/client/petstore/python/petstore_api/models/info.py index 2771d60c2318..354224675139 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/info.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/info.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py index 9dcc377719e8..da6aa3979c76 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/inner_dict_with_property.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py index 60c833c81dcb..885a1b0b2169 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/input_all_of.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py index b57c4c9d0f36..4f346924baa0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py @@ -46,4 +46,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py index c0c5fc4dae85..9c7a35689379 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/list_class.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py index 5e7a0bbfff9a..49aac0619cc1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_of_array_of_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py index 5b46fae4b015..eacfcffee87c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/map_test.py @@ -65,17 +65,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py index e7a6eb1c4604..7432110dec68 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -53,17 +53,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py index ae0d0de0a380..4c6185c0bad8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model200_response.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py index f27857d233e2..ca86a7522db3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_api_response.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py index 672d5a2c1bab..26d71808c4cd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_field.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py index affff9bc82a2..1fec4e618fda 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/model_return.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py index f4429792f542..11b1917671c1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/multi_arrays.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/name.py b/samples/openapi3/client/petstore/python/petstore_api/models/name.py index 7392bcd94a96..82b1e064276e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/name.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py index 836632f92186..cc2bc471fca5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py @@ -61,17 +61,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py index a2100a9d605c..9755c589027b 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_property.py @@ -60,17 +60,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py index 8015d2627315..18f1aea385ac 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/number_only.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py index a0b501f4510e..e3f81ad21526 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_to_test_additional_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py index 607178e61b3e..b92b0fc17dfe 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/object_with_deprecated_fields.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py index e2b2780beece..f4026d2a3f11 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/order.py b/samples/openapi3/client/petstore/python/petstore_api/models/order.py index bb5cf7cebd8b..92c2c1a3b7bf 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/order.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/order.py @@ -67,17 +67,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py index f3c5a1d1a290..114d3b7d45af 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_composite.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py index 98d966c63f88..904a3c679e19 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_object_with_enum_property.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py index 67019aee1760..f02f0bda2fda 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py index 595d04b48cac..84ba2d1cb181 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/parent_with_optional_dict.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py index d10aa6bea0b3..c1997ebaec4c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pet.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pet.py @@ -69,17 +69,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py index 4cc32f18c42d..ae990d4fe765 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -47,4 +47,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py index 8330edb586e5..c559e6ee94f8 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pony_sizes.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py index 6404380de0bf..f5dc8336d0c2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/poop_cleaning.py @@ -72,17 +72,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py index 1dd55054ae68..66ca2d6acad5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/primitive_string.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py index ff945938c081..c9cb24b55232 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_map.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py index 17e3f07aeca9..49e6b8a39dbe 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/property_name_collision.py @@ -50,17 +50,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py index 696299173423..dcd9dc77b1d5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/read_only_first.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py index 7c460b2215df..c98976b4c435 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_circular_all_of_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.circular_all_of_ref import CircularAllOfRef diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py index d034d43bf66f..c56c670b5f3f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/second_ref.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.circular_reference_model import CircularReferenceModel diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py index bf9197fce99f..8e4b63a8f56e 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/self_reference_model.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) from petstore_api.models.dummy_model import DummyModel diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py index e75daa66036b..9485b0d164c5 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_model_name.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py index cb154e1ce529..9dda4787d27a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_name.py @@ -64,17 +64,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py index e5c4b57a1731..8a1e5d4d28b7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tag.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tag.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task.py b/samples/openapi3/client/petstore/python/petstore_api/models/task.py index 68ad30765acc..46581e55fb5a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task.py @@ -51,17 +51,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py index 15b92f1829bf..032a494548d0 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py @@ -48,4 +48,26 @@ def __getattr__(self, name): raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + @classmethod + def from_dict(cls, obj: Dict[str, Any]) -> Self: + """Returns the object represented by the Dict""" + return cls.model_validate(obj, strict=True) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + return cls.model_validate_json(json_str) + + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: + """Returns the dict representation of the actual instance""" + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) + + def to_json(self, exclude_unset: bool = True) -> str: + """Returns the JSON representation of the actual instance""" + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.to_dict(exclude_unset=False)) + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py index 4039342bc999..39184fe47503 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py index 93d9932f5b99..9c9d75d6c262 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py index d67bb5ef1f35..4e5f5f7bbba9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_inline_freeform_additional_properties_request.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py index 36ecd8a5abbb..3ec907de4321 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_model_with_enum_default.py @@ -67,17 +67,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py index 427a35ab86d8..43a97e47d598 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_object_for_multipart_requests_request_marker.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py index 897f0f0b897f..e2ba57da3381 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/tiger.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py index 5f8e42159a24..1b21583f30dd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_model_list_properties.py @@ -49,17 +49,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py index c4e874f931ca..b7def9bdb496 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/unnamed_dict_with_additional_string_list_properties.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py index fefa4c26d8f9..e734f29371cb 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/upload_file_with_additional_properties_request_object.py @@ -48,17 +48,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/user.py b/samples/openapi3/client/petstore/python/petstore_api/models/user.py index a65ce66ddb99..261ba3ebe4c2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/user.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/user.py @@ -55,17 +55,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py index d1d79b8f0b04..8a2efae47855 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/with_nested_one_of.py @@ -52,17 +52,17 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" return cls.model_validate_json(json_str) - def to_dict(self) -> Dict[str, Any]: + def to_dict(self, exclude_unset: bool = True) -> Dict[str, Any]: """Returns the dict representation of the actual instance""" - return self.model_dump(by_alias=True, exclude_unset=True) + return self.model_dump(by_alias=True, exclude_unset=exclude_unset) - def to_json(self) -> str: + def to_json(self, exclude_unset: bool = True) -> str: """Returns the JSON representation of the actual instance""" - return json.dumps(self.model_dump(by_alias=True, exclude_unset=True, mode="json")) + return json.dumps(self.model_dump(by_alias=True, exclude_unset=exclude_unset, mode="json")) def to_str(self) -> str: """Returns the string representation of the model using alias""" - return pprint.pformat(self.to_json()) + return pprint.pformat(self.to_dict(exclude_unset=False)) From a6d46b8a41e9af353ab0b66c8e77cc341c6b4c49 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Wed, 18 Feb 2026 13:43:35 +0100 Subject: [PATCH 10/13] [FIX] tests --- .../resources/python/model_anyof.mustache | 2 + .../resources/python/model_oneof.mustache | 2 + .../petstore_api/models/any_of_color.py | 2 + .../petstore_api/models/any_of_pig.py | 2 + .../petstore_api/models/color.py | 2 + .../petstore_api/models/int_or_string.py | 2 + .../python-aiohttp/petstore_api/models/pig.py | 2 + .../petstore_api/models/task_activity.py | 2 + .../petstore_api/models/any_of_color.py | 2 + .../petstore_api/models/any_of_pig.py | 2 + .../python-httpx/petstore_api/models/color.py | 2 + .../petstore_api/models/int_or_string.py | 2 + .../python-httpx/petstore_api/models/pig.py | 2 + .../petstore_api/models/task_activity.py | 2 + .../petstore_api/models/any_of_color.py | 2 + .../petstore_api/models/any_of_pig.py | 2 + .../petstore_api/models/color.py | 2 + .../petstore_api/models/int_or_string.py | 2 + .../petstore_api/models/one_of_enum_string.py | 2 + .../petstore_api/models/pig.py | 2 + .../petstore_api/models/task_activity.py | 2 + .../petstore_api/models/any_of_color.py | 2 + .../python/petstore_api/models/any_of_pig.py | 2 + .../python/petstore_api/models/color.py | 2 + .../petstore_api/models/int_or_string.py | 2 + .../petstore_api/models/one_of_enum_string.py | 2 + .../python/petstore_api/models/pig.py | 2 + .../petstore_api/models/task_activity.py | 2 + .../petstore/python/tests/test_model.py | 213 ++++++++---------- 29 files changed, 144 insertions(+), 125 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache index 60763f2b24ef..bada2e26e66f 100644 --- a/modules/openapi-generator/src/main/resources/python/model_anyof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_anyof.mustache @@ -1,4 +1,6 @@ from __future__ import annotations +import pprint +import json {{#vendorExtensions.x-py-other-imports}} {{{.}}} {{/vendorExtensions.x-py-other-imports}} diff --git a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache index 7cf093f7a80e..1f7174d5a69f 100644 --- a/modules/openapi-generator/src/main/resources/python/model_oneof.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_oneof.mustache @@ -1,4 +1,6 @@ from __future__ import annotations +import pprint +import json {{#vendorExtensions.x-py-other-imports}} {{{.}}} {{/vendorExtensions.x-py-other-imports}} diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py index fbc45baaec11..48215c24e748 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_color.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py index 1a075fcaf2d1..d6026785be8f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/any_of_pig.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Optional from petstore_api.models.basque_pig import BasquePig diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py index c37defbd0000..0961133b17bd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/color.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py index 4f346924baa0..62cfc27907a3 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/int_or_string.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py index ae990d4fe765..48d19bfa6ace 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/pig.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py index 032a494548d0..419904510fb2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/task_activity.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.bathing import Bathing diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py index fbc45baaec11..48215c24e748 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_color.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py index 1a075fcaf2d1..d6026785be8f 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/any_of_pig.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Optional from petstore_api.models.basque_pig import BasquePig diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py index c37defbd0000..0961133b17bd 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/color.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py index 4f346924baa0..62cfc27907a3 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/int_or_string.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py index ae990d4fe765..48d19bfa6ace 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/pig.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py index 032a494548d0..419904510fb2 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/task_activity.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.bathing import Bathing diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py index fbc45baaec11..48215c24e748 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_color.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py index 1a075fcaf2d1..d6026785be8f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/any_of_pig.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Optional from petstore_api.models.basque_pig import BasquePig diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py index c37defbd0000..0961133b17bd 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/color.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py index 4f346924baa0..62cfc27907a3 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/int_or_string.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py index f4026d2a3f11..bf581392450a 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/one_of_enum_string.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.enum_string1 import EnumString1 diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py index ae990d4fe765..48d19bfa6ace 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/pig.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py index 032a494548d0..419904510fb2 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/task_activity.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.bathing import Bathing diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py index fbc45baaec11..48215c24e748 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_color.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py index 1a075fcaf2d1..d6026785be8f 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/any_of_pig.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Optional from petstore_api.models.basque_pig import BasquePig diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/color.py b/samples/openapi3/client/petstore/python/petstore_api/models/color.py index c37defbd0000..0961133b17bd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/color.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/color.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py index 4f346924baa0..62cfc27907a3 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/int_or_string.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from typing_extensions import Annotated diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py index f4026d2a3f11..bf581392450a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/one_of_enum_string.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.enum_string1 import EnumString1 diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py index ae990d4fe765..48d19bfa6ace 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/pig.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/pig.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.basque_pig import BasquePig diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py index 032a494548d0..419904510fb2 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/task_activity.py @@ -13,6 +13,8 @@ from __future__ import annotations +import pprint +import json from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator from typing import Any, List, Optional from petstore_api.models.bathing import Bathing diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index 6049def8b885..837e191c2fb0 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -92,38 +92,25 @@ def test_oneOf_array_of_integers(self): # test new Color new_color = petstore_api.Color() self.assertEqual("null", new_color.to_json()) - self.assertEqual(None, new_color.actual_instance) + self.assertIsNone(new_color.root) - # test the oneof schema validator - json_str = '[12,34,56]' - array_of_integers = json.loads(json_str) - # no error should be thrown - new_color.oneof_schema_1_validator = array_of_integers - new_color.actual_instance = array_of_integers - new_color.actual_instance = None - - # test the oneof schema validator with invalid input - json_str = '[12,34,56120938]' - array_of_integers = json.loads(json_str) - try: - new_color.oneof_schema_1_validator = array_of_integers - except ValueError as e: - self.assertTrue("Input should be less than or equal to 255" in str(e)) - - try: - new_color.actual_instance = array_of_integers - except ValueError as e: - self.assertTrue("Input should be less than or equal to 255" in str(e)) - - # test from_josn + # test from_json json_str = '[12,34,56]' p = petstore_api.Color.from_json(json_str) - self.assertEqual(p.actual_instance, [12, 34, 56]) + self.assertEqual(p.root, [12, 34, 56]) try: - p = petstore_api.Color.from_json('[2342112,0,0,0]') - except ValueError as e: - self.assertTrue("Input should be less than or equal to 255" in str(e)) + petstore_api.Color.from_json('[1.1,0]') + except ValidationError as e: + # 2 validation errors for Color + # list[int].0 + # Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=1.1, input_type=float] + # For further information visit https://errors.pydantic.dev/2.12/v/int_from_float + # str + # Input should be a valid string [type=string_type, input_value=[1.1, 0], input_type=list] + # For further information visit https://errors.pydantic.dev/2.12/v/string_type + self.assertIn("list[int].0", str(e)) + self.assertIn("Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=1.1, input_type=float]", str(e)) # test to_json, to_dict method json_str = '[12,34,56]' @@ -131,10 +118,6 @@ def test_oneOf_array_of_integers(self): self.assertEqual(p.to_json(), "[12, 34, 56]") self.assertEqual(p.to_dict(), [12, 34, 56]) - # test nullable - p = petstore_api.Color.from_json(None) - self.assertEqual(p.actual_instance, None) - def test_oneof_enum_string_from_json(self): # test from_json oneof_enum = petstore_api.OneOfEnumString.from_json('"a"') @@ -167,116 +150,97 @@ def test_oneof_nested_from_json_invalid(self): def test_oneof_enum_string(self): # test the constructor enum_string1 = petstore_api.EnumString1('a') - constructor1 = petstore_api.OneOfEnumString(actual_instance=enum_string1) - self.assertEqual(constructor1.actual_instance, enum_string1) + constructor1 = petstore_api.OneOfEnumString(root=enum_string1) + self.assertEqual(constructor1.root, enum_string1) constructor2 = petstore_api.OneOfEnumString(enum_string1) - self.assertEqual(constructor2.actual_instance, enum_string1) - constructor3 = petstore_api.OneOfEnumString() - self.assertEqual(constructor3.actual_instance, None) + self.assertEqual(constructor2.root, enum_string1) + try: + petstore_api.OneOfEnumString() + except ValidationError as e: + self.assertIn("Input should be 'a' or 'b' [type=enum, input_value=PydanticUndefined, input_type=PydanticUndefinedType]", str(e)) + self.assertIn("Input should be 'c' or 'd' [type=enum, input_value=PydanticUndefined, input_type=PydanticUndefinedType]", str(e)) def test_anyOf_array_of_integers(self): - # test new Color + # test new Color new_color = petstore_api.AnyOfColor() self.assertEqual("null", new_color.to_json()) - self.assertEqual(None, new_color.actual_instance) + self.assertEqual(None, new_color.root) # test the oneof schema validator json_str = '[12,34,56]' array_of_integers = json.loads(json_str) - # no error should be thrown - new_color.anyof_schema_1_validator = array_of_integers - new_color.actual_instance = array_of_integers + petstore_api.AnyOfColor(array_of_integers) - # test the oneof schema validator with invalid input - json_str = '[12,34,56120938]' - array_of_integers = json.loads(json_str) + # test the oneof schema validator with invalid input + array_of_integers = [12, 34, 5.6] try: - new_color.anyof_schema_1_validator = array_of_integers - except ValueError as e: - self.assertIn("Input should be less than or equal to 255", str(e)) + petstore_api.AnyOfColor.from_dict(array_of_integers) + except ValidationError as e: + self.assertIn("list[int].2", str(e)) + self.assertIn("Input should be a valid integer [type=int_type, input_value=5.6, input_type=float]", str(e)) + self.assertIn("Input should be a valid string [type=string_type, input_value=[12, 34, 5.6], input_type=list]", str(e)) - try: - new_color.actual_instance = array_of_integers - except ValueError as e: - self.assertIn("Input should be less than or equal to 255", str(e)) # test from_josn json_str = '[12,34,56]' p = petstore_api.AnyOfColor.from_json(json_str) - self.assertEqual(p.actual_instance, [12, 34,56]) + self.assertEqual(p.root, [12, 34,56]) try: - p = petstore_api.AnyOfColor.from_json('[2342112,0,0,0]') - except ValueError as e: - self.assertIn("Input should be less than or equal to 255", str(e)) + petstore_api.AnyOfColor.from_json('[0,1.1,0]') + except ValidationError as e: + self.assertIn("list[int].1", str(e)) + self.assertIn("Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=1.1, input_type=float]", str(e)) + self.assertIn("Input should be a valid string [type=string_type, input_value=[0, 1.1, 0], input_type=list]", str(e)) def test_oneOf(self): # test new Pig bp = petstore_api.BasquePig.from_dict({"className": "BasquePig", "color": "red"}) - new_pig = petstore_api.Pig() - self.assertEqual("null", new_pig.to_json()) - self.assertEqual(None, new_pig.actual_instance) - new_pig2 = petstore_api.Pig(actual_instance=bp) + new_pig2 = petstore_api.Pig(bp) self.assertEqual('{"className": "BasquePig", "color": "red"}', new_pig2.to_json()) new_pig3 = petstore_api.Pig(bp) self.assertEqual('{"className": "BasquePig", "color": "red"}', new_pig3.to_json()) try: - new_pig4 = petstore_api.Pig(bp, actual_instance=bp) - except ValueError as e: - self.assertTrue("If position argument is used, keyword argument cannot be used.", str(e)) + petstore_api.Pig(bp, root=bp) + except TypeError as e: + self.assertTrue("RootModel.__init__() got multiple values for argument 'root'", str(e)) try: - new_pig5 = petstore_api.Pig(bp, bp) - except ValueError as e: - self.assertTrue("If position argument is used, only 1 is allowed to set `actual_instance`", str(e)) + petstore_api.Pig(bp, root=bp) + except TypeError as e: + self.assertTrue("RootModel.__init__() got multiple values for argument 'root'", str(e)) # test from_json json_str = '{"className": "BasquePig", "color": "red"}' p = petstore_api.Pig.from_json(json_str) - self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + self.assertIsInstance(p.root, petstore_api.BasquePig) # test from_dict json_dict = {"className": "BasquePig", "color": "red"} p = petstore_api.Pig.from_dict(json_dict) - self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + self.assertIsInstance(p.root, petstore_api.BasquePig) # test init - basque_pig = p.actual_instance - pig2 = petstore_api.Pig(actual_instance=basque_pig) - self.assertIsInstance(pig2.actual_instance, petstore_api.BasquePig) + basque_pig = p.root + pig2 = petstore_api.Pig(basque_pig) + self.assertIsInstance(pig2.root, petstore_api.BasquePig) # test failed init try: - pig3 = petstore_api.Pig(actual_instance="123") + petstore_api.Pig(root="123") self.assertTrue(False) # this line shouldn't execute - except ValueError as e: - # pydantic_core._pydantic_core.ValidationError: 2 validation errors for Pig - # actual_instance.BasquePig - # Input should be a valid dictionary or instance of BasquePig [type=model_type, input_value='123', input_type=str] - # For further information visit https://errors.pydantic.dev/2.3/v/model_type - # actual_instance.DanishPig - # Input should be a valid dictionary or instance of DanishPig [type=model_type, input_value='123', input_type=str] - # For further information visit https://errors.pydantic.dev/2.3/v/model_type - self.assertIn("or instance of BasquePig", str(e)) - self.assertIn("or instance of DanishPig", str(e)) + except ValidationError as e: + self.assertIn("Input should be a valid dictionary or instance of BasquePig [type=model_type, input_value='123', input_type=str]", str(e)) + self.assertIn("Input should be a valid dictionary or instance of DanishPig [type=model_type, input_value='123', input_type=str]", str(e)) # failure try: - p2 = petstore_api.Pig.from_json("1") + petstore_api.Pig.from_json("1") self.assertTrue(False) # this line shouldn't execute - except AttributeError as e: - self.assertEqual(str(e), "'int' object has no attribute 'get'") - # comment out below as the error message is different using oneOf discriminator lookup option - #except ValueError as e: - # error_message = ( - # "No match found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. " - # "Details: 1 validation error for BasquePig\n" - # "__root__\n" - # " BasquePig expected dict not int (type=type_error), 1 validation error for DanishPig\n" - # "__root__\n" - # " DanishPig expected dict not int (type=type_error)") - # self.assertEqual(str(e), error_message) + except ValidationError as e: + self.assertIn("BasquePig", str(e)) + self.assertIn("DanishPig", str(e)) + self.assertIn("Input should be an object [type=model_type, input_value=1, input_type=int]", str(e)) - # test to_json self.assertEqual(p.to_json(), '{"className": "BasquePig", "color": "red"}') # test nested property @@ -289,45 +253,44 @@ def test_oneOf(self): self.assertEqual(nested2.to_json(), nested_json) def test_anyOf(self): - # test new AnyOfPig - new_anypig = petstore_api.AnyOfPig() - self.assertEqual("null", new_anypig.to_json()) - self.assertEqual(None, new_anypig.actual_instance) - # test from_json json_str = '{"className": "BasquePig", "color": "red"}' p = petstore_api.AnyOfPig.from_json(json_str) - self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + self.assertIsInstance(p.root, petstore_api.BasquePig) # test from_dict json_dict = {"className": "BasquePig", "color": "red"} p = petstore_api.AnyOfPig.from_dict(json_dict) - self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + self.assertIsInstance(p.root, petstore_api.BasquePig) # test init - basque_pig = p.actual_instance - pig2 = petstore_api.AnyOfPig(actual_instance=basque_pig) - self.assertIsInstance(pig2.actual_instance, petstore_api.BasquePig) + basque_pig = p.root + pig2 = petstore_api.AnyOfPig(root=basque_pig) + self.assertIsInstance(pig2.root, petstore_api.BasquePig) # test failed init try: - pig3 = petstore_api.AnyOfPig(actual_instance="123") + petstore_api.AnyOfPig(root="123") self.assertTrue(False) # this line shouldn't execute - except ValueError as e: - # pydantic_core._pydantic_core.ValidationError: 1 validation error for AnyOfPig - # actual_instance - # Value error, No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: Error! Input type `` is not `BasquePig`, Error! Input type `` is not `DanishPig` [type=value_error, input_value='123', input_type=str] - # For further information visit https://errors.pydantic.dev/2.4/v/value_error - self.assertIn("No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, DanishPig.", str(e)) - self.assertIn("Input type `` is not `BasquePig`", str(e)) - self.assertIn("Input type `` is not `DanishPig`", str(e)) + except ValidationError as e: + # 2 validation errors for AnyOfPig + # BasquePig + # Input should be a valid dictionary or instance of BasquePig [type=model_type, input_value='123', input_type=str] + # For further information visit https://errors.pydantic.dev/2.12/v/model_type + # DanishPig + # Input should be a valid dictionary or instance of DanishPig [type=model_type, input_value='123', input_type=str] + # For further information visit https://errors.pydantic.dev/2.12/v/model_type + self.assertIn("Input should be a valid dictionary or instance of BasquePig [type=model_type, input_value='123', input_type=str]", str(e)) + self.assertIn("Input should be a valid dictionary or instance of DanishPig [type=model_type, input_value='123', input_type=str]", str(e)) # failure try: - p2 = petstore_api.AnyOfPig.from_json("1") + petstore_api.AnyOfPig.from_json("1") self.assertTrue(False) # this line shouldn't execute - except ValueError as e: - self.assertIn("No match found when deserializing the JSON string into AnyOfPig with anyOf schemas: BasquePig, DanishPig", str(e)) + except ValidationError as e: + self.assertIn("BasquePig", str(e)) + self.assertIn("DanishPig", str(e)) + self.assertIn("Input should be an object [type=model_type, input_value=1, input_type=int]", str(e)) # test to_json self.assertEqual(p.to_json(), '{"className": "BasquePig", "color": "red"}') @@ -571,9 +534,9 @@ def test_nullable_property_pattern(self): def test_int_or_string_oneof(self): a = petstore_api.IntOrString("-efg") - self.assertEqual(a.actual_instance, "-efg") + self.assertEqual(a.root, "-efg") a = petstore_api.IntOrString(100) - self.assertEqual(a.actual_instance, 100) + self.assertEqual(a.root, 100) try: a = petstore_api.IntOrString(1) @@ -641,18 +604,18 @@ class TestdditionalPropertiesAnyType(unittest.TestCase): def test_additional_properties(self): a1 = petstore_api.AdditionalPropertiesAnyType() a1.additional_properties = { "abc": 123 } - self.assertEqual(a1.to_dict(), {"abc": 123}) - self.assertEqual(a1.to_json(), '{"abc": 123}') + self.assertEqual(a1.to_dict(), {"additional_properties": {"abc": 123}}) + self.assertEqual(a1.to_json(), '{"additional_properties": {"abc": 123}}') a2 = petstore_api.AdditionalPropertiesObject() a2.additional_properties = { "efg": 45.6 } - self.assertEqual(a2.to_dict(), {"efg": 45.6}) - self.assertEqual(a2.to_json(), '{"efg": 45.6}') + self.assertEqual(a2.to_dict(), {"additional_properties": {"efg": 45.6}}) + self.assertEqual(a2.to_json(), '{"additional_properties": {"efg": 45.6}}') a3 = petstore_api.AdditionalPropertiesWithDescriptionOnly() a3.additional_properties = { "xyz": 45.6 } - self.assertEqual(a3.to_dict(), {"xyz": 45.6}) - self.assertEqual(a3.to_json(), '{"xyz": 45.6}') + self.assertEqual(a3.to_dict(), {"additional_properties": {"xyz": 45.6}}) + self.assertEqual(a3.to_json(), '{"additional_properties": {"xyz": 45.6}}') class TestUnnamedDictWithAdditionalStringListProperties: def test_empty_dict(self): From 8d576af2d4143c5a9c5cc6cae2a81969816bba19 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Wed, 18 Feb 2026 13:53:43 +0100 Subject: [PATCH 11/13] [FIX] tests --- .../client/petstore/python/tests/test_model.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index 837e191c2fb0..27ea11054047 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -143,9 +143,17 @@ def test_oneof_nested_from_dict(self): def test_oneof_nested_from_json_invalid(self): try: - nested2 = petstore_api.WithNestedOneOf.from_json('{"size": 1, "nested_oneof_enum_string": "e"}') + petstore_api.WithNestedOneOf.from_json('{"size": 1, "nested_oneof_enum_string": "e"}') except ValueError as e: - self.assertTrue("'e' is not a valid EnumString1, 'e' is not a valid EnumString" in str(e)) + # pydantic_core._pydantic_core.ValidationError: 2 validation errors for WithNestedOneOf + # nested_oneof_enum_string.str-enum[EnumString1] + # Input should be 'a' or 'b' [type=enum, input_value='e', input_type=str] + # For further information visit https://errors.pydantic.dev/2.12/v/enum + # nested_oneof_enum_string.str-enum[EnumString2] + # Input should be 'c' or 'd' [type=enum, input_value='e', input_type=str] + # For further information visit https://errors.pydantic.dev/2.12/v/enum + self.assertIn("Input should be 'a' or 'b' [type=enum, input_value='e', input_type=str]", str(e)) + self.assertIn("Input should be 'c' or 'd' [type=enum, input_value='e', input_type=str]", str(e)) def test_oneof_enum_string(self): # test the constructor @@ -387,8 +395,8 @@ def test_inline_enum_validator(self): try: self.pet.status = "error" self.assertTrue(False, "should have failed with 'invalid status' error") # this line shouldn't execute - except ValueError as e: - self.assertTrue("must be one of enum values ('available', 'pending', 'sold')" in str(e)) + except ValidationError as e: + self.assertIn("Input should be 'available', 'pending' or 'sold' [type=literal_error, input_value='error', input_type=str]", str(e)) def test_constraints(self): rgb = [128, 128, 128] From 213781022ce0d32893b5b3f250cf73def72be522 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Wed, 18 Feb 2026 14:00:11 +0100 Subject: [PATCH 12/13] [FIX] tests --- .../petstore/python/tests/test_model.py | 40 +++---------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index 27ea11054047..e647a286209e 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -78,16 +78,6 @@ def test_equal(self): self.pet1.tags = [] self.assertFalse(self.pet1 == self.pet2) - def test_oneof_schema_2_validator(self): - new_color = petstore_api.Color() - array_of_integers = [12, 34, 56] - - try: - new_color.oneof_schema_2_validator = array_of_integers - self.fail(f"Should have failed: {new_color.oneof_schema_2_validator}") - except ValueError as e: - self.assertTrue("List should have at least 4 items after validation, not 3" in str(e)) - def test_oneOf_array_of_integers(self): # test new Color new_color = petstore_api.Color() @@ -404,32 +394,14 @@ def test_constraints(self): hex_color = "#00FF00" # These should all pass - color = petstore_api.Color(oneof_schema_1_validator=rgb) - self.assertEqual(rgb, color.oneof_schema_1_validator) - - color = petstore_api.Color(oneof_schema_2_validator=rgba) - self.assertEqual(rgba, color.oneof_schema_2_validator) - - color = petstore_api.Color(oneof_schema_3_validator=hex_color) - self.assertEqual(hex_color, color.oneof_schema_3_validator) + color = petstore_api.Color(rgb) + self.assertEqual(rgb, color.root) - try: - petstore_api.Color(oneof_schema_1_validator=rgba) - self.fail("invalid validation") - except ValidationError as e: - self.assertIn("List should have at most 3 items after validation, not 4", str(e)) + color = petstore_api.Color(rgba) + self.assertEqual(rgba, color.root) - try: - petstore_api.Color(oneof_schema_2_validator=rgb) - self.fail("invalid validation") - except ValidationError as e: - self.assertIn("List should have at least 4 items after validation, not 3", str(e)) - - try: - petstore_api.Color(oneof_schema_3_validator="too long string") - self.fail("invalid validation") - except ValidationError as e: - self.assertIn("String should have at most 7 characters", str(e)) + color = petstore_api.Color(hex_color) + self.assertEqual(hex_color, color.root) def test_object_id(self): pet_ap = petstore_api.Pet(name="test name", photoUrls=["string"]) From e260bb207214dd5f40eca8ba9f888675986ecd18 Mon Sep 17 00:00:00 2001 From: Pavel Slabko Date: Wed, 18 Feb 2026 14:06:00 +0100 Subject: [PATCH 13/13] OH MY --- .../python-lazyImports/tests/test_model.py | 373 ++++++++---------- .../petstore/python/tests/test_model.py | 2 +- 2 files changed, 174 insertions(+), 201 deletions(-) diff --git a/samples/openapi3/client/petstore/python-lazyImports/tests/test_model.py b/samples/openapi3/client/petstore/python-lazyImports/tests/test_model.py index 6049def8b885..d2783e376b34 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/tests/test_model.py +++ b/samples/openapi3/client/petstore/python-lazyImports/tests/test_model.py @@ -34,9 +34,9 @@ def test_cat(self): self.assertEqual("cat", self.cat.class_name) self.assertEqual("red", self.cat.color) cat_str = ("{'additional_properties': {},\n" - " 'className': 'cat',\n" - " 'color': 'red',\n" - " 'declawed': None}") + " 'className': 'cat',\n" + " 'color': 'red',\n" + " 'declawed': None}") self.assertEqual(cat_str, self.cat.to_str()) def test_to_str(self): @@ -78,52 +78,31 @@ def test_equal(self): self.pet1.tags = [] self.assertFalse(self.pet1 == self.pet2) - def test_oneof_schema_2_validator(self): - new_color = petstore_api.Color() - array_of_integers = [12, 34, 56] - - try: - new_color.oneof_schema_2_validator = array_of_integers - self.fail(f"Should have failed: {new_color.oneof_schema_2_validator}") - except ValueError as e: - self.assertTrue("List should have at least 4 items after validation, not 3" in str(e)) - def test_oneOf_array_of_integers(self): # test new Color new_color = petstore_api.Color() self.assertEqual("null", new_color.to_json()) - self.assertEqual(None, new_color.actual_instance) - - # test the oneof schema validator - json_str = '[12,34,56]' - array_of_integers = json.loads(json_str) - # no error should be thrown - new_color.oneof_schema_1_validator = array_of_integers - new_color.actual_instance = array_of_integers - new_color.actual_instance = None - - # test the oneof schema validator with invalid input - json_str = '[12,34,56120938]' - array_of_integers = json.loads(json_str) - try: - new_color.oneof_schema_1_validator = array_of_integers - except ValueError as e: - self.assertTrue("Input should be less than or equal to 255" in str(e)) - - try: - new_color.actual_instance = array_of_integers - except ValueError as e: - self.assertTrue("Input should be less than or equal to 255" in str(e)) + self.assertIsNone(new_color.root) - # test from_josn + # test from_json json_str = '[12,34,56]' p = petstore_api.Color.from_json(json_str) - self.assertEqual(p.actual_instance, [12, 34, 56]) + self.assertEqual(p.root, [12, 34, 56]) try: - p = petstore_api.Color.from_json('[2342112,0,0,0]') - except ValueError as e: - self.assertTrue("Input should be less than or equal to 255" in str(e)) + petstore_api.Color.from_json('[1.1,0]') + except ValidationError as e: + # 2 validation errors for Color + # list[int].0 + # Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=1.1, input_type=float] + # For further information visit https://errors.pydantic.dev/2.12/v/int_from_float + # str + # Input should be a valid string [type=string_type, input_value=[1.1, 0], input_type=list] + # For further information visit https://errors.pydantic.dev/2.12/v/string_type + self.assertIn("list[int].0", str(e)) + self.assertIn( + "Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=1.1, input_type=float]", + str(e)) # test to_json, to_dict method json_str = '[12,34,56]' @@ -131,10 +110,6 @@ def test_oneOf_array_of_integers(self): self.assertEqual(p.to_json(), "[12, 34, 56]") self.assertEqual(p.to_dict(), [12, 34, 56]) - # test nullable - p = petstore_api.Color.from_json(None) - self.assertEqual(p.actual_instance, None) - def test_oneof_enum_string_from_json(self): # test from_json oneof_enum = petstore_api.OneOfEnumString.from_json('"a"') @@ -143,7 +118,7 @@ def test_oneof_nested_from_enum_string(self): # test from_dict oneof_enum = petstore_api.OneOfEnumString.from_dict("a") assert oneof_enum is not None - nested = petstore_api.WithNestedOneOf(size = 1, nested_oneof_enum_string = oneof_enum) + nested = petstore_api.WithNestedOneOf(size=1, nested_oneof_enum_string=oneof_enum) # test to_json self.assertEqual(nested.to_json(), '{"size": 1, "nested_oneof_enum_string": "a"}') @@ -160,127 +135,127 @@ def test_oneof_nested_from_dict(self): def test_oneof_nested_from_json_invalid(self): try: - nested2 = petstore_api.WithNestedOneOf.from_json('{"size": 1, "nested_oneof_enum_string": "e"}') - except ValueError as e: - self.assertTrue("'e' is not a valid EnumString1, 'e' is not a valid EnumString" in str(e)) + petstore_api.WithNestedOneOf.from_json('{"size": 1, "nested_oneof_enum_string": "e"}') + except ValidationError as e: + # pydantic_core._pydantic_core.ValidationError: 2 validation errors for WithNestedOneOf + # nested_oneof_enum_string.str-enum[EnumString1] + # Input should be 'a' or 'b' [type=enum, input_value='e', input_type=str] + # For further information visit https://errors.pydantic.dev/2.12/v/enum + # nested_oneof_enum_string.str-enum[EnumString2] + # Input should be 'c' or 'd' [type=enum, input_value='e', input_type=str] + # For further information visit https://errors.pydantic.dev/2.12/v/enum + self.assertIn("Input should be 'a' or 'b' [type=enum, input_value='e', input_type=str]", str(e)) + self.assertIn("Input should be 'c' or 'd' [type=enum, input_value='e', input_type=str]", str(e)) def test_oneof_enum_string(self): # test the constructor enum_string1 = petstore_api.EnumString1('a') - constructor1 = petstore_api.OneOfEnumString(actual_instance=enum_string1) - self.assertEqual(constructor1.actual_instance, enum_string1) + constructor1 = petstore_api.OneOfEnumString(root=enum_string1) + self.assertEqual(constructor1.root, enum_string1) constructor2 = petstore_api.OneOfEnumString(enum_string1) - self.assertEqual(constructor2.actual_instance, enum_string1) - constructor3 = petstore_api.OneOfEnumString() - self.assertEqual(constructor3.actual_instance, None) + self.assertEqual(constructor2.root, enum_string1) + try: + petstore_api.OneOfEnumString() + except ValidationError as e: + self.assertIn( + "Input should be 'a' or 'b' [type=enum, input_value=PydanticUndefined, input_type=PydanticUndefinedType]", + str(e)) + self.assertIn( + "Input should be 'c' or 'd' [type=enum, input_value=PydanticUndefined, input_type=PydanticUndefinedType]", + str(e)) def test_anyOf_array_of_integers(self): - # test new Color + # test new Color new_color = petstore_api.AnyOfColor() self.assertEqual("null", new_color.to_json()) - self.assertEqual(None, new_color.actual_instance) + self.assertEqual(None, new_color.root) # test the oneof schema validator json_str = '[12,34,56]' array_of_integers = json.loads(json_str) - # no error should be thrown - new_color.anyof_schema_1_validator = array_of_integers - new_color.actual_instance = array_of_integers - - # test the oneof schema validator with invalid input - json_str = '[12,34,56120938]' - array_of_integers = json.loads(json_str) - try: - new_color.anyof_schema_1_validator = array_of_integers - except ValueError as e: - self.assertIn("Input should be less than or equal to 255", str(e)) + petstore_api.AnyOfColor(array_of_integers) + # test the oneof schema validator with invalid input + array_of_integers = [12, 34, 5.6] try: - new_color.actual_instance = array_of_integers - except ValueError as e: - self.assertIn("Input should be less than or equal to 255", str(e)) + petstore_api.AnyOfColor.from_dict(array_of_integers) + except ValidationError as e: + self.assertIn("list[int].2", str(e)) + self.assertIn("Input should be a valid integer [type=int_type, input_value=5.6, input_type=float]", str(e)) + self.assertIn( + "Input should be a valid string [type=string_type, input_value=[12, 34, 5.6], input_type=list]", str(e)) # test from_josn json_str = '[12,34,56]' p = petstore_api.AnyOfColor.from_json(json_str) - self.assertEqual(p.actual_instance, [12, 34,56]) + self.assertEqual(p.root, [12, 34, 56]) try: - p = petstore_api.AnyOfColor.from_json('[2342112,0,0,0]') - except ValueError as e: - self.assertIn("Input should be less than or equal to 255", str(e)) + petstore_api.AnyOfColor.from_json('[0,1.1,0]') + except ValidationError as e: + self.assertIn("list[int].1", str(e)) + self.assertIn( + "Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=1.1, input_type=float]", + str(e)) + self.assertIn("Input should be a valid string [type=string_type, input_value=[0, 1.1, 0], input_type=list]", + str(e)) def test_oneOf(self): # test new Pig bp = petstore_api.BasquePig.from_dict({"className": "BasquePig", "color": "red"}) - new_pig = petstore_api.Pig() - self.assertEqual("null", new_pig.to_json()) - self.assertEqual(None, new_pig.actual_instance) - new_pig2 = petstore_api.Pig(actual_instance=bp) + new_pig2 = petstore_api.Pig(bp) self.assertEqual('{"className": "BasquePig", "color": "red"}', new_pig2.to_json()) new_pig3 = petstore_api.Pig(bp) self.assertEqual('{"className": "BasquePig", "color": "red"}', new_pig3.to_json()) try: - new_pig4 = petstore_api.Pig(bp, actual_instance=bp) - except ValueError as e: - self.assertTrue("If position argument is used, keyword argument cannot be used.", str(e)) + petstore_api.Pig(bp, root=bp) + except TypeError as e: + self.assertTrue("RootModel.__init__() got multiple values for argument 'root'", str(e)) try: - new_pig5 = petstore_api.Pig(bp, bp) - except ValueError as e: - self.assertTrue("If position argument is used, only 1 is allowed to set `actual_instance`", str(e)) + petstore_api.Pig(bp, root=bp) + except TypeError as e: + self.assertTrue("RootModel.__init__() got multiple values for argument 'root'", str(e)) # test from_json json_str = '{"className": "BasquePig", "color": "red"}' p = petstore_api.Pig.from_json(json_str) - self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + self.assertIsInstance(p.root, petstore_api.BasquePig) # test from_dict json_dict = {"className": "BasquePig", "color": "red"} p = petstore_api.Pig.from_dict(json_dict) - self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + self.assertIsInstance(p.root, petstore_api.BasquePig) # test init - basque_pig = p.actual_instance - pig2 = petstore_api.Pig(actual_instance=basque_pig) - self.assertIsInstance(pig2.actual_instance, petstore_api.BasquePig) + basque_pig = p.root + pig2 = petstore_api.Pig(basque_pig) + self.assertIsInstance(pig2.root, petstore_api.BasquePig) # test failed init try: - pig3 = petstore_api.Pig(actual_instance="123") + petstore_api.Pig(root="123") self.assertTrue(False) # this line shouldn't execute - except ValueError as e: - # pydantic_core._pydantic_core.ValidationError: 2 validation errors for Pig - # actual_instance.BasquePig - # Input should be a valid dictionary or instance of BasquePig [type=model_type, input_value='123', input_type=str] - # For further information visit https://errors.pydantic.dev/2.3/v/model_type - # actual_instance.DanishPig - # Input should be a valid dictionary or instance of DanishPig [type=model_type, input_value='123', input_type=str] - # For further information visit https://errors.pydantic.dev/2.3/v/model_type - self.assertIn("or instance of BasquePig", str(e)) - self.assertIn("or instance of DanishPig", str(e)) + except ValidationError as e: + self.assertIn( + "Input should be a valid dictionary or instance of BasquePig [type=model_type, input_value='123', input_type=str]", + str(e)) + self.assertIn( + "Input should be a valid dictionary or instance of DanishPig [type=model_type, input_value='123', input_type=str]", + str(e)) # failure try: - p2 = petstore_api.Pig.from_json("1") + petstore_api.Pig.from_json("1") self.assertTrue(False) # this line shouldn't execute - except AttributeError as e: - self.assertEqual(str(e), "'int' object has no attribute 'get'") - # comment out below as the error message is different using oneOf discriminator lookup option - #except ValueError as e: - # error_message = ( - # "No match found when deserializing the JSON string into Pig with oneOf schemas: BasquePig, DanishPig. " - # "Details: 1 validation error for BasquePig\n" - # "__root__\n" - # " BasquePig expected dict not int (type=type_error), 1 validation error for DanishPig\n" - # "__root__\n" - # " DanishPig expected dict not int (type=type_error)") - # self.assertEqual(str(e), error_message) + except ValidationError as e: + self.assertIn("BasquePig", str(e)) + self.assertIn("DanishPig", str(e)) + self.assertIn("Input should be an object [type=model_type, input_value=1, input_type=int]", str(e)) - # test to_json self.assertEqual(p.to_json(), '{"className": "BasquePig", "color": "red"}') # test nested property - nested = petstore_api.WithNestedOneOf(size = 1, nested_pig = p) + nested = petstore_api.WithNestedOneOf(size=1, nested_pig=p) self.assertEqual(nested.to_json(), '{"size": 1, "nested_pig": {"className": "BasquePig", "color": "red"}}') nested_json = nested.to_json() @@ -289,45 +264,48 @@ def test_oneOf(self): self.assertEqual(nested2.to_json(), nested_json) def test_anyOf(self): - # test new AnyOfPig - new_anypig = petstore_api.AnyOfPig() - self.assertEqual("null", new_anypig.to_json()) - self.assertEqual(None, new_anypig.actual_instance) - # test from_json json_str = '{"className": "BasquePig", "color": "red"}' p = petstore_api.AnyOfPig.from_json(json_str) - self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + self.assertIsInstance(p.root, petstore_api.BasquePig) # test from_dict json_dict = {"className": "BasquePig", "color": "red"} p = petstore_api.AnyOfPig.from_dict(json_dict) - self.assertIsInstance(p.actual_instance, petstore_api.BasquePig) + self.assertIsInstance(p.root, petstore_api.BasquePig) # test init - basque_pig = p.actual_instance - pig2 = petstore_api.AnyOfPig(actual_instance=basque_pig) - self.assertIsInstance(pig2.actual_instance, petstore_api.BasquePig) + basque_pig = p.root + pig2 = petstore_api.AnyOfPig(root=basque_pig) + self.assertIsInstance(pig2.root, petstore_api.BasquePig) # test failed init try: - pig3 = petstore_api.AnyOfPig(actual_instance="123") + petstore_api.AnyOfPig(root="123") self.assertTrue(False) # this line shouldn't execute - except ValueError as e: - # pydantic_core._pydantic_core.ValidationError: 1 validation error for AnyOfPig - # actual_instance - # Value error, No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, DanishPig. Details: Error! Input type `` is not `BasquePig`, Error! Input type `` is not `DanishPig` [type=value_error, input_value='123', input_type=str] - # For further information visit https://errors.pydantic.dev/2.4/v/value_error - self.assertIn("No match found when setting the actual_instance in AnyOfPig with anyOf schemas: BasquePig, DanishPig.", str(e)) - self.assertIn("Input type `` is not `BasquePig`", str(e)) - self.assertIn("Input type `` is not `DanishPig`", str(e)) + except ValidationError as e: + # 2 validation errors for AnyOfPig + # BasquePig + # Input should be a valid dictionary or instance of BasquePig [type=model_type, input_value='123', input_type=str] + # For further information visit https://errors.pydantic.dev/2.12/v/model_type + # DanishPig + # Input should be a valid dictionary or instance of DanishPig [type=model_type, input_value='123', input_type=str] + # For further information visit https://errors.pydantic.dev/2.12/v/model_type + self.assertIn( + "Input should be a valid dictionary or instance of BasquePig [type=model_type, input_value='123', input_type=str]", + str(e)) + self.assertIn( + "Input should be a valid dictionary or instance of DanishPig [type=model_type, input_value='123', input_type=str]", + str(e)) # failure try: - p2 = petstore_api.AnyOfPig.from_json("1") + petstore_api.AnyOfPig.from_json("1") self.assertTrue(False) # this line shouldn't execute - except ValueError as e: - self.assertIn("No match found when deserializing the JSON string into AnyOfPig with anyOf schemas: BasquePig, DanishPig", str(e)) + except ValidationError as e: + self.assertIn("BasquePig", str(e)) + self.assertIn("DanishPig", str(e)) + self.assertIn("Input should be an object [type=model_type, input_value=1, input_type=int]", str(e)) # test to_json self.assertEqual(p.to_json(), '{"className": "BasquePig", "color": "red"}') @@ -342,7 +320,7 @@ def test_inheritance(self): self.assertEqual(dog2.breed, 'bulldog') self.assertEqual(dog2.class_name, "dog") self.assertEqual(dog2.color, 'white') - + def test_inheritance_discriminators(self): model = petstore_api.DiscriminatorAllOfSuper.from_dict({"elementType": "DiscriminatorAllOfSub"}) self.assertIsInstance(model, petstore_api.DiscriminatorAllOfSub) @@ -373,7 +351,8 @@ def test_enum_ref_property(self): # test to_json d = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1) self.assertEqual(d.to_json(), '{"value": 1}') - d2 = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1, str_value=petstore_api.OuterEnum.DELIVERED) + d2 = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1, + str_value=petstore_api.OuterEnum.DELIVERED) self.assertEqual(d2.to_json(), '{"str_value": "delivered", "value": 1}') # test from_json (round trip) d3 = petstore_api.OuterObjectWithEnumProperty.from_json(d2.to_json()) @@ -385,22 +364,24 @@ def test_enum_ref_property(self): self.assertEqual(d4.to_json(), '{"value": 1, "str_value": null}') d5 = petstore_api.OuterObjectWithEnumProperty(value=petstore_api.OuterEnumInteger.NUMBER_1) self.assertEqual(d5.model_fields_set, {'value'}) - d5.str_value = None # set None explicitly + d5.str_value = None # set None explicitly self.assertEqual(d5.model_fields_set, {'value', 'str_value'}) self.assertEqual(d5.to_json(), '{"value": 1, "str_value": null}') def test_valdiator(self): # test regular expression - a = petstore_api.FormatTest(number=123.45, byte=bytes("string", 'utf-8'), date=date(2013, 9, 17), password="testing09876") + a = petstore_api.FormatTest(number=123.45, byte=bytes("string", 'utf-8'), date=date(2013, 9, 17), + password="testing09876") try: a.pattern_with_digits_and_delimiter = "123" - self.assertTrue(False) # this line shouldn't execute + self.assertTrue(False) # this line shouldn't execute except ValueError as e: self.assertTrue(r"must validate the regular expression /^image_\d{1,3}$/i" in str(e)) # test None with optional string (with regualr expression) - a = petstore_api.FormatTest(number=123.45, byte=bytes("string", 'utf-8'), date=date(2013, 9, 17), password="testing09876") - a.string = None # shouldn't throw an exception + a = petstore_api.FormatTest(number=123.45, byte=bytes("string", 'utf-8'), date=date(2013, 9, 17), + password="testing09876") + a.string = None # shouldn't throw an exception a.pattern_with_digits_and_delimiter = "IMAGE_123" self.assertEqual(a.pattern_with_digits_and_delimiter, "IMAGE_123") @@ -408,24 +389,29 @@ def test_valdiator(self): self.assertEqual(a.pattern_with_digits_and_delimiter, "image_123") # test sanitize for serialization with different data types - self.assertEqual(petstore_api.ApiClient().sanitize_for_serialization(a), {'byte': b'string', 'date': '2013-09-17', 'number': 123.45, 'password': 'testing09876', 'pattern_with_digits_and_delimiter': 'image_123'}) + self.assertEqual(petstore_api.ApiClient().sanitize_for_serialization(a), + {'byte': b'string', 'date': '2013-09-17', 'number': 123.45, 'password': 'testing09876', + 'pattern_with_digits_and_delimiter': 'image_123'}) # test sanitize for serialization with SecretStr (format: password) class LoginTest(BaseModel): username: StrictStr = Field(min_length=2, strict=True, max_length=64) password: SecretStr - + l = LoginTest(username="admin", password=SecretStr("testing09876")) - self.assertEqual(petstore_api.ApiClient().sanitize_for_serialization(l), {'username': "admin", 'password': "testing09876"}) + self.assertEqual(petstore_api.ApiClient().sanitize_for_serialization(l), + {'username': "admin", 'password': "testing09876"}) def test_inline_enum_validator(self): self.pet = petstore_api.Pet(name="test name", photoUrls=["string"]) self.pet.id = 1 try: self.pet.status = "error" - self.assertTrue(False, "should have failed with 'invalid status' error") # this line shouldn't execute - except ValueError as e: - self.assertTrue("must be one of enum values ('available', 'pending', 'sold')" in str(e)) + self.assertTrue(False, "should have failed with 'invalid status' error") # this line shouldn't execute + except ValidationError as e: + self.assertIn( + "Input should be 'available', 'pending' or 'sold' [type=literal_error, input_value='error', input_type=str]", + str(e)) def test_constraints(self): rgb = [128, 128, 128] @@ -433,32 +419,14 @@ def test_constraints(self): hex_color = "#00FF00" # These should all pass - color = petstore_api.Color(oneof_schema_1_validator=rgb) - self.assertEqual(rgb, color.oneof_schema_1_validator) - - color = petstore_api.Color(oneof_schema_2_validator=rgba) - self.assertEqual(rgba, color.oneof_schema_2_validator) - - color = petstore_api.Color(oneof_schema_3_validator=hex_color) - self.assertEqual(hex_color, color.oneof_schema_3_validator) + color = petstore_api.Color(rgb) + self.assertEqual(rgb, color.root) - try: - petstore_api.Color(oneof_schema_1_validator=rgba) - self.fail("invalid validation") - except ValidationError as e: - self.assertIn("List should have at most 3 items after validation, not 4", str(e)) - - try: - petstore_api.Color(oneof_schema_2_validator=rgb) - self.fail("invalid validation") - except ValidationError as e: - self.assertIn("List should have at least 4 items after validation, not 3", str(e)) + color = petstore_api.Color(rgba) + self.assertEqual(rgba, color.root) - try: - petstore_api.Color(oneof_schema_3_validator="too long string") - self.fail("invalid validation") - except ValidationError as e: - self.assertIn("String should have at most 7 characters", str(e)) + color = petstore_api.Color(hex_color) + self.assertEqual(hex_color, color.root) def test_object_id(self): pet_ap = petstore_api.Pet(name="test name", photoUrls=["string"]) @@ -469,7 +437,6 @@ def test_object_id(self): pet_ap4 = petstore_api.Pet.from_dict(pet_ap.to_dict()) self.assertNotEqual(id(pet_ap3), id(pet_ap4)) - def test_additional_properties(self): pet_ap = petstore_api.Pet(name="test name", photoUrls=["string"]) pet_ap.id = 1 @@ -482,14 +449,15 @@ def test_additional_properties(self): self.assertNotEqual(id(pet_ap.additional_properties), id(pet_ap2.additional_properties)) pet_ap.additional_properties["something-new"] = "haha" - self.assertEqual(pet_ap.to_json(), '{"id": 1, "name": "test name", "photoUrls": ["string"], "status": "available", "something-new": "haha"}') + self.assertEqual(pet_ap.to_json(), + '{"id": 1, "name": "test name", "photoUrls": ["string"], "status": "available", "something-new": "haha"}') self.assertEqual(type(pet_ap2.additional_properties), dict) self.assertNotEqual(id(pet_ap.additional_properties), id(pet_ap2.additional_properties)) self.assertEqual(pet_ap.additional_properties["something-new"], "haha") try: _tmp = pet_ap2.additional_properties["something-new"] - self.assertTrue(False) # this line shouldn't execute + self.assertTrue(False) # this line shouldn't execute except KeyError as e: self.assertEqual("'something-new'", str(e)) @@ -512,16 +480,16 @@ def test_nullable(self): h.nullable_message = None self.assertEqual(h.to_json(), '{"NullableMessage": null}') - #import json - #dictionary ={ - # "id": "04", - # "name": "sunil", + # import json + # dictionary ={ + # "id": "04", + # "name": "sunil", # "department": None - #} - # - ## Serializing json - #json_object = json.dumps(dictionary) - #self.assertEqual(json_object, "") + # } + # + ## Serializing json + # json_object = json.dumps(dictionary) + # self.assertEqual(json_object, "") def test_inline_enum_default(self): enum_test = petstore_api.EnumTest(enum_string_required="lower") @@ -571,9 +539,9 @@ def test_nullable_property_pattern(self): def test_int_or_string_oneof(self): a = petstore_api.IntOrString("-efg") - self.assertEqual(a.actual_instance, "-efg") + self.assertEqual(a.root, "-efg") a = petstore_api.IntOrString(100) - self.assertEqual(a.actual_instance, 100) + self.assertEqual(a.root, 100) try: a = petstore_api.IntOrString(1) @@ -594,7 +562,7 @@ def test_array_of_array_of_model(self): a = petstore_api.ArrayOfArrayOfModel() t = petstore_api.Tag(id=123, name="tag name") a.another_property = [[t]] - self.assertEqual(a.to_dict(), {'another_property': [[ {'id': 123, 'name': 'tag name'} ]]}) + self.assertEqual(a.to_dict(), {'another_property': [[{'id': 123, 'name': 'tag name'}]]}) self.assertEqual(a.to_json(), '{"another_property": [[{"id": 123, "name": "tag name"}]]}') a2 = petstore_api.ArrayOfArrayOfModel.from_dict(a.to_dict()) assert a2 is not None @@ -602,7 +570,7 @@ def test_array_of_array_of_model(self): def test_object_with_additional_properties(self): a = petstore_api.ObjectToTestAdditionalProperties() - a.additional_properties = { "abc": 123 } + a.additional_properties = {"abc": 123} # should not throw the following errors: # pydantic.errors.ConfigError: field "additional_properties" not yet prepared so type is still a ForwardRef, you might need to call ObjectToTestAdditionalProperties.update_forward_refs(). @@ -621,8 +589,10 @@ def test_allof(self): def test_allof_circular_imports(self): # for issue 18271 - model_a = petstore_api.models.circular_all_of_ref.CircularAllOfRef.from_json('{"_name": "nameA", "second_circular_all_of_ref": {"name": "nameB"}}') - model_b = petstore_api.models.second_circular_all_of_ref.SecondCircularAllOfRef.from_json('{"_name": "nameB", "circular_all_of_ref": {"name": "nameA"}}') + model_a = petstore_api.models.circular_all_of_ref.CircularAllOfRef.from_json( + '{"_name": "nameA", "second_circular_all_of_ref": {"name": "nameB"}}') + model_b = petstore_api.models.second_circular_all_of_ref.SecondCircularAllOfRef.from_json( + '{"_name": "nameB", "circular_all_of_ref": {"name": "nameA"}}') # shouldn't throw ImportError assert model_a is not None assert model_b is not None @@ -637,22 +607,24 @@ def test_allof_discriminator_mapping(self): assert user_info is not None self.assertEqual(user_info.to_json(), user_info_json) + class TestdditionalPropertiesAnyType(unittest.TestCase): def test_additional_properties(self): a1 = petstore_api.AdditionalPropertiesAnyType() - a1.additional_properties = { "abc": 123 } - self.assertEqual(a1.to_dict(), {"abc": 123}) - self.assertEqual(a1.to_json(), '{"abc": 123}') + a1.additional_properties = {"abc": 123} + self.assertEqual(a1.to_dict(), {"additional_properties": {"abc": 123}}) + self.assertEqual(a1.to_json(), '{"additional_properties": {"abc": 123}}') a2 = petstore_api.AdditionalPropertiesObject() - a2.additional_properties = { "efg": 45.6 } - self.assertEqual(a2.to_dict(), {"efg": 45.6}) - self.assertEqual(a2.to_json(), '{"efg": 45.6}') + a2.additional_properties = {"efg": 45.6} + self.assertEqual(a2.to_dict(), {"additional_properties": {"efg": 45.6}}) + self.assertEqual(a2.to_json(), '{"additional_properties": {"efg": 45.6}}') a3 = petstore_api.AdditionalPropertiesWithDescriptionOnly() - a3.additional_properties = { "xyz": 45.6 } - self.assertEqual(a3.to_dict(), {"xyz": 45.6}) - self.assertEqual(a3.to_json(), '{"xyz": 45.6}') + a3.additional_properties = {"xyz": 45.6} + self.assertEqual(a3.to_dict(), {"additional_properties": {"xyz": 45.6}}) + self.assertEqual(a3.to_json(), '{"additional_properties": {"xyz": 45.6}}') + class TestUnnamedDictWithAdditionalStringListProperties: def test_empty_dict(self): @@ -669,6 +641,7 @@ def test_single_string_item(self): a = petstore_api.UnnamedDictWithAdditionalStringListProperties(dictProperty={"b": ["c"]}) assert a.to_dict() == {"dictProperty": {"b": ["c"]}} + class TestUnnamedDictWithAdditionalModelListProperties: def test_empty_dict(self): a = petstore_api.UnnamedDictWithAdditionalModelListProperties(dictProperty={}) diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index e647a286209e..0ef62ddc5b7a 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -134,7 +134,7 @@ def test_oneof_nested_from_dict(self): def test_oneof_nested_from_json_invalid(self): try: petstore_api.WithNestedOneOf.from_json('{"size": 1, "nested_oneof_enum_string": "e"}') - except ValueError as e: + except ValidationError as e: # pydantic_core._pydantic_core.ValidationError: 2 validation errors for WithNestedOneOf # nested_oneof_enum_string.str-enum[EnumString1] # Input should be 'a' or 'b' [type=enum, input_value='e', input_type=str]