diff --git a/packages/open-api-gateway/README.md b/packages/open-api-gateway/README.md index d7b3d003b..622a1b634 100644 --- a/packages/open-api-gateway/README.md +++ b/packages/open-api-gateway/README.md @@ -1311,9 +1311,41 @@ The Smithy-based projects are compatible with the [Smithy IntelliJ Plugin](https * Right-click on the `smithy/build.gradle` file in your Smithy API project * Select "Link Gradle Project" +### Tagging Operations + +Operations can be grouped together into logical collections via tags. This can be achieved in Smithy with the `@tags` trait: + +```smithy +@tags(["pets", "users"]) +operation PurchasePet { + ... +} +``` + +Or in OpenAPI using the `tags` property: + +```yaml +paths: + /pets/purchase: + post: + operationId: purchasePet + tags: + - pets + - users + ... +``` + +When multiple tags are used, the "first" tag is considered to be the API that the operation belongs to, so in the generated client, the above example operation would be included in the `PetsApi` client but not the `UsersApi` client. + +Multiple tags are still useful for documentation generation, for example `DocumentationFormat.HTML_REDOC` will group operations by tag in the side navigation bar. + +If you would like to introduce tags without breaking existing clients, we recommend first adding a tag named `default` to all operations. + +⚠️ __Important Note__: Smithy version 1.27.2 and below sorts tags in alphabetical order and so the "first" tag will be the earliest in the alphabet. Therefore, if using tags in Smithy, we currently recommend prefixing your desired first tag with an underscore (`_`). This will be rectified in the next Smithy release, where tag order from the `@tags` trait will be preserved. + ### Breaking Changes * `v0.14.0` - see https://github.com/aws/aws-prototyping-sdk/pull/280 * Moved smithy model files from `model` directory to `smithy/src/main/smithy` - please move these manually as part of upgrading to `0.14.0`, and delete your `model` directory when done. * Moved smithy gradle files from `smithy-build` directory to `smithy` - if you have added any dependencies to your `smithy-build/build.gradle` file you will need to copy them across into `smithy/build.gradle` (note dependencies in the new gradle file start with `implementation` rather than `smithy`). - * Deprecated `gradleWrapperPath` option on SmithApiGateway projects in favour of `ignoreGradleWrapper: false` - the gradle wrapper in `smithy` directory is always used (and generated automatically if not found). If you used a custom gradle wrapper, copy it into the `smithy` directory, set `ignoreGradleWrapper: false` and check it in to your repository. \ No newline at end of file + * Deprecated `gradleWrapperPath` option on SmithApiGateway projects in favour of `ignoreGradleWrapper: false` - the gradle wrapper in `smithy` directory is always used (and generated automatically if not found). If you used a custom gradle wrapper, copy it into the `smithy` directory, set `ignoreGradleWrapper: false` and check it in to your repository. diff --git a/packages/open-api-gateway/scripts/generators/docs/openapitools.json b/packages/open-api-gateway/scripts/generators/docs/openapitools.json index 6bd00a46c..d0473cce3 100644 --- a/packages/open-api-gateway/scripts/generators/docs/openapitools.json +++ b/packages/open-api-gateway/scripts/generators/docs/openapitools.json @@ -2,7 +2,7 @@ "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", "spaces": 2, "generator-cli": { - "version": "6.0.0", + "version": "6.3.0", "storageDir": "~/.open-api-generator-cli" } } \ No newline at end of file diff --git a/packages/open-api-gateway/scripts/generators/generate b/packages/open-api-gateway/scripts/generators/generate index 5cff6d61a..5e19d1456 100755 --- a/packages/open-api-gateway/scripts/generators/generate +++ b/packages/open-api-gateway/scripts/generators/generate @@ -8,6 +8,7 @@ output_path='' generator='' generator_dir='' additional_properties='' +openapi_normalizer='' src_dir='src' while [[ "$#" -gt 0 ]]; do case $1 in --spec-path) spec_path="$2"; shift;; @@ -15,6 +16,7 @@ while [[ "$#" -gt 0 ]]; do case $1 in --generator) generator="$2"; shift;; --generator-dir) generator_dir="$2"; shift;; --additional-properties) additional_properties="$2"; shift;; + --openapi-normalizer) openapi_normalizer="$2"; shift;; --src-dir) src_dir="$2"; shift;; esac; shift; done @@ -52,6 +54,7 @@ run_command @openapitools/openapi-generator-cli generate \ --template-dir templates \ --config config.final.yaml \ --additional-properties="$additional_properties" \ + ${openapi_normalizer:+"--openapi-normalizer=$openapi_normalizer"} \ --input-spec $spec_path \ --output $output_path diff --git a/packages/open-api-gateway/scripts/generators/java/openapitools.json b/packages/open-api-gateway/scripts/generators/java/openapitools.json index e444fd206..d0473cce3 100644 --- a/packages/open-api-gateway/scripts/generators/java/openapitools.json +++ b/packages/open-api-gateway/scripts/generators/java/openapitools.json @@ -2,7 +2,7 @@ "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", "spaces": 2, "generator-cli": { - "version": "6.0.1", + "version": "6.3.0", "storageDir": "~/.open-api-generator-cli" } } \ No newline at end of file diff --git a/packages/open-api-gateway/scripts/generators/python/openapitools.json b/packages/open-api-gateway/scripts/generators/python/openapitools.json index 0d7390267..d0473cce3 100644 --- a/packages/open-api-gateway/scripts/generators/python/openapitools.json +++ b/packages/open-api-gateway/scripts/generators/python/openapitools.json @@ -2,7 +2,7 @@ "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", "spaces": 2, "generator-cli": { - "version": "6.1.0", + "version": "6.3.0", "storageDir": "~/.open-api-generator-cli" } } \ No newline at end of file diff --git a/packages/open-api-gateway/scripts/generators/typescript/openapitools.json b/packages/open-api-gateway/scripts/generators/typescript/openapitools.json index 6bd00a46c..d0473cce3 100644 --- a/packages/open-api-gateway/scripts/generators/typescript/openapitools.json +++ b/packages/open-api-gateway/scripts/generators/typescript/openapitools.json @@ -2,7 +2,7 @@ "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", "spaces": 2, "generator-cli": { - "version": "6.0.0", + "version": "6.3.0", "storageDir": "~/.open-api-generator-cli" } } \ No newline at end of file diff --git a/packages/open-api-gateway/src/project/codegen/components/generated-java-client-source-code.ts b/packages/open-api-gateway/src/project/codegen/components/generated-java-client-source-code.ts index cdc41d8da..43f7ae318 100644 --- a/packages/open-api-gateway/src/project/codegen/components/generated-java-client-source-code.ts +++ b/packages/open-api-gateway/src/project/codegen/components/generated-java-client-source-code.ts @@ -71,6 +71,9 @@ export class GeneratedJavaClientSourceCode extends Component { ].join("\\ "), }, srcDir: path.join("src", "main", "java", ...invokerPackage.split(".")), + normalizers: { + KEEP_ONLY_FIRST_TAG_IN_OPERATION: true, + }, }); } } diff --git a/packages/open-api-gateway/src/project/codegen/components/generated-python-client-source-code.ts b/packages/open-api-gateway/src/project/codegen/components/generated-python-client-source-code.ts index 0a2cbab77..59dc62051 100644 --- a/packages/open-api-gateway/src/project/codegen/components/generated-python-client-source-code.ts +++ b/packages/open-api-gateway/src/project/codegen/components/generated-python-client-source-code.ts @@ -47,7 +47,7 @@ export class GeneratedPythonClientSourceCode extends Component { // Generate the python client logger.debug("Generating python client..."); invokeOpenApiGenerator({ - generator: "python-experimental", + generator: "python", specPath: this.options.specPath, outputPath: this.project.outdir, generatorDirectory: ClientLanguage.PYTHON, @@ -57,6 +57,9 @@ export class GeneratedPythonClientSourceCode extends Component { }, // Tell the generator where python source files live srcDir: (this.project as PythonProject).moduleName, + normalizers: { + KEEP_ONLY_FIRST_TAG_IN_OPERATION: true, + }, }); } } diff --git a/packages/open-api-gateway/src/project/codegen/components/generated-typescript-client-source-code.ts b/packages/open-api-gateway/src/project/codegen/components/generated-typescript-client-source-code.ts index 2155ec61f..841cf28ac 100644 --- a/packages/open-api-gateway/src/project/codegen/components/generated-typescript-client-source-code.ts +++ b/packages/open-api-gateway/src/project/codegen/components/generated-typescript-client-source-code.ts @@ -60,6 +60,9 @@ export class GeneratedTypescriptClientSourceCode extends Component { supportsES6: "true", }, srcDir: (this.project as TypeScriptProject).srcdir, + normalizers: { + KEEP_ONLY_FIRST_TAG_IN_OPERATION: true, + }, }); // Write an index.ts which exposes the additional generated file OperationConfig.ts, which contains handler wrappers diff --git a/packages/open-api-gateway/src/project/codegen/components/utils.ts b/packages/open-api-gateway/src/project/codegen/components/utils.ts index 2783cadf6..14f8da666 100644 --- a/packages/open-api-gateway/src/project/codegen/components/utils.ts +++ b/packages/open-api-gateway/src/project/codegen/components/utils.ts @@ -17,6 +17,12 @@ export enum NonClientGeneratorDirectory { */ export type GeneratorDirectory = ClientLanguage | NonClientGeneratorDirectory; +/** + * Types of normalizers supported by openapi-generator + * @see https://openapi-generator.tech/docs/customization/#openapi-normalizer + */ +export type OpenApiNormalizer = "KEEP_ONLY_FIRST_TAG_IN_OPERATION"; + /** * Options for generating client code or docs using OpenAPI Generator CLI */ @@ -48,6 +54,11 @@ export interface GenerationOptions { * (eg. operation config) should be placed. */ readonly srcDir?: string; + /** + * Normalizers to apply to the spec prior to generation, if any + * @see https://openapi-generator.tech/docs/customization/#openapi-normalizer + */ + readonly normalizers?: Partial>; } const serializeProperties = (properties: { [key: string]: string }) => @@ -95,8 +106,17 @@ export const invokeOpenApiGenerator = (options: GenerationOptions) => { options.additionalProperties )}"` : ""; + + const normalizers = options.normalizers + ? ` --openapi-normalizer "${serializeProperties( + Object.fromEntries( + Object.entries(options.normalizers).map(([k, v]) => [k, `${v}`]) + ) + )}"` + : ""; + exec( - `./generate --generator ${options.generator} --spec-path ${options.specPath} --output-path ${options.outputPath} --generator-dir ${options.generatorDirectory} --src-dir ${srcDir}${additionalProperties}`, + `./generate --generator ${options.generator} --spec-path ${options.specPath} --output-path ${options.outputPath} --generator-dir ${options.generatorDirectory} --src-dir ${srcDir}${additionalProperties}${normalizers}`, { cwd: path.resolve( __dirname, diff --git a/packages/open-api-gateway/src/project/codegen/generated-java-client-project.ts b/packages/open-api-gateway/src/project/codegen/generated-java-client-project.ts index 8c003f70d..613a4ef11 100644 --- a/packages/open-api-gateway/src/project/codegen/generated-java-client-project.ts +++ b/packages/open-api-gateway/src/project/codegen/generated-java-client-project.ts @@ -22,15 +22,15 @@ export interface GeneratedJavaClientProjectOptions extends JavaProjectOptions { const DEPENDENCIES: string[] = [ // Required for open api generated client - "io.swagger/swagger-annotations@1.6.5", + "io.swagger/swagger-annotations@1.6.8", "com.google.code.findbugs/jsr305@3.0.2", - "com.squareup.okhttp3/okhttp@4.9.3", - "com.squareup.okhttp3/logging-interceptor@4.9.3", - "com.google.code.gson/gson@2.9.0", + "com.squareup.okhttp3/okhttp@4.10.0", + "com.squareup.okhttp3/logging-interceptor@4.10.0", + "com.google.code.gson/gson@2.9.1", "io.gsonfire/gson-fire@1.8.5", "org.apache.commons/commons-lang3@3.12.0", "jakarta.annotation/jakarta.annotation-api@1.3.5", - "org.openapitools/jackson-databind-nullable@0.2.2", + "org.openapitools/jackson-databind-nullable@0.2.4", "javax.ws.rs/jsr311-api@1.1.1", "javax.ws.rs/javax.ws.rs-api@2.1.1", // For handler wrappers @@ -41,7 +41,7 @@ const DEPENDENCIES: string[] = [ ]; const TEST_DEPENDENCIES: string[] = [ - "org.junit.jupiter/junit-jupiter-api@5.8.2", + "org.junit.jupiter/junit-jupiter-api@5.9.1", "org.mockito/mockito-core@3.12.4", ]; diff --git a/packages/open-api-gateway/src/project/spec/components/parsed-spec.ts b/packages/open-api-gateway/src/project/spec/components/parsed-spec.ts index 68463944f..37136f664 100644 --- a/packages/open-api-gateway/src/project/spec/components/parsed-spec.ts +++ b/packages/open-api-gateway/src/project/spec/components/parsed-spec.ts @@ -1,10 +1,13 @@ /*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ import * as path from "path"; +import { getLogger } from "log4js"; import type { OpenAPIV3 } from "openapi-types"; import { Component, Project } from "projen"; import { exec, tryReadFileSync } from "projen/lib/util"; +const logger = getLogger(); + /** * Configuration for the ParsedSpec component */ @@ -62,9 +65,10 @@ export class ParsedSpec extends Component { const parsedSpec: OpenAPIV3.Document = JSON.parse(singleSpecFile); - // TODO: Remove this validation and update mustache templates as appropriate when the following has been addressed: - // https://github.com/OpenAPITools/openapi-generator/pull/14568 - // Check that each operation has zero or one tags + // To avoid duplicating custom generated code (eg. OperationConfig or handler wrappers) and causing build errors, we + // will apply the OpenAPI Normalizer to KEEP_ONLY_FIRST_TAG_IN_OPERATION when generating code. Tags are still + // preserved in the specification to allow for better documentation. + // See: https://github.com/OpenAPITools/openapi-generator/pull/14465 const operationsWithMultipleTags = Object.entries(parsedSpec.paths).flatMap( ([urlPath, methods]) => Object.entries(methods ?? {}) @@ -79,10 +83,10 @@ export class ParsedSpec extends Component { ); if (operationsWithMultipleTags.length > 0) { - throw new Error( - `Operations with multiple tags are not yet supported, please tag operations with at most one tag. The following operations have multiple tags: ${operationsWithMultipleTags.join( + logger.warn( + `The following operations had multiple tags: ${operationsWithMultipleTags.join( ", " - )}` + )}. Code will only be generated for each operation's first tag.` ); } } diff --git a/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-java-client-source-code.test.ts.snap b/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-java-client-source-code.test.ts.snap index 02b77e9b6..3711adb19 100644 --- a/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-java-client-source-code.test.ts.snap +++ b/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-java-client-source-code.test.ts.snap @@ -173,7 +173,7 @@ src/test/java/test/test/client/model/TestRequestTest.java src/test/java/test/test/client/model/TestResponseMessagesInnerTest.java src/test/java/test/test/client/model/TestResponseTest.java ", - ".openapi-generator/VERSION": "6.0.1", + ".openapi-generator/VERSION": "6.3.0", ".projen/deps.json": Object { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", "dependencies": Array [ @@ -645,19 +645,11 @@ components: - errorMessage type: object TestRequest: - example: - myInput: 0.8008281904610115 properties: myInput: type: number type: object TestResponse: - example: - messages: - - id: 0 - message: message - - id: 0 - message: message properties: messages: items: @@ -667,9 +659,6 @@ components: - messages type: object TestResponse_messages_inner: - example: - id: 0 - message: message properties: message: type: string @@ -695,7 +684,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.3.0' + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' } } @@ -747,7 +736,7 @@ if(hasProperty('target') && target == 'android') { task.from variant.javaCompile.destinationDir task.destinationDir = project.file(\\"\${project.buildDir}/outputs/jar\\") task.archiveName = \\"\${project.name}-\${variant.baseName}-\${version}.jar\\" - artifacts.add('archives', task); + artifacts.add('archives', task) } } @@ -788,20 +777,20 @@ ext { } dependencies { - implementation 'io.swagger:swagger-annotations:1.6.5' + implementation 'io.swagger:swagger-annotations:1.6.8' implementation \\"com.google.code.findbugs:jsr305:3.0.2\\" - implementation 'com.squareup.okhttp3:okhttp:4.9.3' - implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3' - implementation 'com.google.code.gson:gson:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.10.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' + implementation 'com.google.code.gson:gson:2.9.1' implementation 'io.gsonfire:gson-fire:1.8.5' implementation 'javax.ws.rs:jsr311-api:1.1.1' implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1' - implementation 'org.openapitools:jackson-databind-nullable:0.2.3' + implementation 'org.openapitools:jackson-databind-nullable:0.2.4' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' implementation \\"jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version\\" - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1' testImplementation 'org.mockito:mockito-core:3.12.4' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1' } javadoc { @@ -861,19 +850,20 @@ test { resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( \\"io.swagger\\" % \\"swagger-annotations\\" % \\"1.6.5\\", - \\"com.squareup.okhttp3\\" % \\"okhttp\\" % \\"4.9.3\\", - \\"com.squareup.okhttp3\\" % \\"logging-interceptor\\" % \\"4.9.3\\", - \\"com.google.code.gson\\" % \\"gson\\" % \\"2.9.0\\", + \\"com.squareup.okhttp3\\" % \\"okhttp\\" % \\"4.10.0\\", + \\"com.squareup.okhttp3\\" % \\"logging-interceptor\\" % \\"4.10.0\\", + \\"com.google.code.gson\\" % \\"gson\\" % \\"2.9.1\\", \\"org.apache.commons\\" % \\"commons-lang3\\" % \\"3.12.0\\", \\"javax.ws.rs\\" % \\"jsr311-api\\" % \\"1.1.1\\", \\"javax.ws.rs\\" % \\"javax.ws.rs-api\\" % \\"2.1.1\\", - \\"org.openapitools\\" % \\"jackson-databind-nullable\\" % \\"0.2.3\\", + \\"org.openapitools\\" % \\"jackson-databind-nullable\\" % \\"0.2.4\\", \\"io.gsonfire\\" % \\"gson-fire\\" % \\"1.8.5\\" % \\"compile\\", \\"jakarta.annotation\\" % \\"jakarta.annotation-api\\" % \\"1.3.5\\" % \\"compile\\", \\"com.google.code.findbugs\\" % \\"jsr305\\" % \\"3.0.2\\" % \\"compile\\", \\"jakarta.annotation\\" % \\"jakarta.annotation-api\\" % \\"1.3.5\\" % \\"compile\\", - \\"org.junit.jupiter\\" % \\"junit-jupiter-api\\" % \\"5.8.2\\" % \\"test\\", - \\"com.novocode\\" % \\"junit-interface\\" % \\"0.10\\" % \\"test\\" + \\"org.junit.jupiter\\" % \\"junit-jupiter-api\\" % \\"5.9.1\\" % \\"test\\", + \\"com.novocode\\" % \\"junit-interface\\" % \\"0.10\\" % \\"test\\", + \\"org.mockito\\" % \\"mockito-core\\" % \\"3.12.4\\" % \\"test\\" ) ) ", @@ -2000,7 +1990,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-enforcer-plugin - 3.0.0 + 3.1.0 enforce-maven @@ -2043,6 +2033,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal maven-dependency-plugin + 3.3.0 package @@ -2059,7 +2050,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-jar-plugin - 3.2.0 + 3.3.0 @@ -2073,7 +2064,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.codehaus.mojo build-helper-maven-plugin - 3.2.0 + 3.3.0 add_sources @@ -2104,7 +2095,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-javadoc-plugin - 3.3.2 + 3.4.1 attach-javadocs @@ -2127,7 +2118,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-source-plugin - 3.2.0 + 3.2.1 attach-sources @@ -2207,11 +2198,6 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal - - io.swagger - swagger-annotations - \${swagger-core-version} - com.google.code.findbugs @@ -2254,6 +2240,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal jackson-databind-nullable \${jackson-databind-nullable-version} + javax.ws.rs jsr311-api @@ -2289,19 +2276,19 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal \${java.version} \${java.version} 1.8.5 - 1.6.5 - 4.9.3 - 2.9.0 + 1.6.6 + 4.10.0 + 2.9.1 3.12.0 - 0.2.3 + 0.2.4 1.3.5 - 5.8.2 - 1.6.2 + 5.9.1 + 1.9.1 3.12.4 2.1.1 1.1.1 UTF-8 - 2.21.0 + 2.27.2 ", @@ -2443,6 +2430,15 @@ import test.test.client.auth.ApiKeyAuth; public class ApiClient { private String basePath = \\"http://localhost\\"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + \\"\\", + \\"No description provided\\", + new HashMap() + ) + )); + protected Integer serverIndex = 0; + protected Map serverVariables = null; private boolean debugging = false; private Map defaultHeaderMap = new HashMap(); private Map defaultCookieMap = new HashMap(); @@ -2536,6 +2532,33 @@ public class ApiClient { return this; } + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + /** * Get HTTP client * @@ -2660,7 +2683,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setDateFormat(DateFormat dateFormat) { - this.json.setDateFormat(dateFormat); + JSON.setDateFormat(dateFormat); return this; } @@ -2671,7 +2694,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setSqlDateFormat(DateFormat dateFormat) { - this.json.setSqlDateFormat(dateFormat); + JSON.setSqlDateFormat(dateFormat); return this; } @@ -2682,7 +2705,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - this.json.setOffsetDateTimeFormat(dateFormat); + JSON.setOffsetDateTimeFormat(dateFormat); return this; } @@ -2693,7 +2716,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { - this.json.setLocalDateFormat(dateFormat); + JSON.setLocalDateFormat(dateFormat); return this; } @@ -2704,7 +2727,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setLenientOnJson(boolean lenientOnJson) { - this.json.setLenientOnJson(lenientOnJson); + JSON.setLenientOnJson(lenientOnJson); return this; } @@ -2797,6 +2820,18 @@ public class ApiClient { throw new RuntimeException(\\"No OAuth2 authentication configured!\\"); } + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException(\\"No AWS4 authentication configured!\\"); + } + /** * Set the User-Agent header's value (by adding to the default header map). * @@ -2965,7 +3000,7 @@ public class ApiClient { return \\"\\"; } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { //Serialize to json string and remove the \\" enclosing characters - String jsonStr = json.serialize(param); + String jsonStr = JSON.serialize(param); return jsonStr.substring(1, jsonStr.length() - 1); } else if (param instanceof Collection) { StringBuilder b = new StringBuilder(); @@ -2973,7 +3008,7 @@ public class ApiClient { if (b.length() > 0) { b.append(\\",\\"); } - b.append(String.valueOf(o)); + b.append(o); } return b.toString(); } else { @@ -3224,7 +3259,7 @@ public class ApiClient { contentType = \\"application/json\\"; } if (isJsonMime(contentType)) { - return json.deserialize(respBody, returnType); + return JSON.deserialize(respBody, returnType); } else if (returnType.equals(String.class)) { // Expecting string, return the raw response body. return (T) respBody; @@ -3258,11 +3293,13 @@ public class ApiClient { } else if (isJsonMime(contentType)) { String content; if (obj != null) { - content = json.serialize(obj); + content = JSON.serialize(obj); } else { content = null; } return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); } else { throw new ApiException(\\"Content type \\\\\\"\\" + contentType + \\"\\\\\\" is not supported\\"); } @@ -3553,7 +3590,18 @@ public class ApiClient { if (baseUrl != null) { url.append(baseUrl).append(path); } else { - url.append(basePath).append(path); + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + \\"Invalid index %d when selecting the host settings. Must be less than %d\\", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); } if (queryParams != null && !queryParams.isEmpty()) { @@ -3682,11 +3730,12 @@ public class ApiClient { for (Object item: list) { if (item instanceof File) { addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); } } } else { - Headers partHeaders = Headers.of(\\"Content-Disposition\\", \\"form-data; name=\\\\\\"\\" + param.getKey() + \\"\\\\\\"\\"); - mpBuilder.addPart(partHeaders, RequestBody.create(parameterToString(param.getValue()), null)); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); } } return mpBuilder.build(); @@ -3720,6 +3769,31 @@ public class ApiClient { mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); } + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse(\\"text/plain\\")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse(\\"application/json\\")); + } + + Headers partHeaders = Headers.of(\\"Content-Disposition\\", \\"form-data; name=\\\\\\"\\" + key + \\"\\\\\\"\\"); + mpBuilder.addPart(partHeaders, requestBody); + } + /** * Get network interceptor to add it to the httpClient to track download progress for * async requests. @@ -3787,7 +3861,7 @@ public class ApiClient { KeyStore caKeyStore = newEmptyKeyStore(password); int index = 0; for (Certificate certificate : certificates) { - String certificateAlias = \\"ca\\" + Integer.toString(index++); + String certificateAlias = \\"ca\\" + (index++); caKeyStore.setCertificateEntry(certificateAlias, certificate); } trustManagerFactory.init(caKeyStore); @@ -3820,7 +3894,7 @@ public class ApiClient { /** * Convert the HTTP request body to a string. * - * @param request The HTTP request object + * @param requestBody The HTTP request object * @return The string representation of the HTTP request body * @throws test.test.client.ApiException If fail to serialize the request body object into a string */ @@ -3941,7 +4015,7 @@ public class ApiException extends Exception { * @param responseBody the response body */ public ApiException(int code, Map> responseHeaders, String responseBody) { - this((String) null, (Throwable) null, code, responseHeaders, responseBody); + this(\\"Response Code: \\" + code + \\" Response Body: \\" + responseBody, (Throwable) null, code, responseHeaders, responseBody); } /** @@ -4862,7 +4936,7 @@ public class ServerConfiguration { throw new IllegalArgumentException(\\"The variable \\" + name + \\" in the server URL has invalid value \\" + value + \\".\\"); } } - url = url.replaceAll(\\"\\\\\\\\{\\" + name + \\"\\\\\\\\}\\", value); + url = url.replace(\\"{\\" + name + \\"}\\", value); } return url; } @@ -5080,7 +5154,7 @@ public class DefaultApi { // create path and map variables String localVarPath = \\"/operation/{pathParam}\\" - .replaceAll(\\"\\\\\\\\{\\" + \\"pathParam\\" + \\"\\\\\\\\}\\", localVarApiClient.escapeString(pathParam.toString())); + .replace(\\"{\\" + \\"pathParam\\" + \\"}\\", localVarApiClient.escapeString(pathParam.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -5110,20 +5184,17 @@ public class DefaultApi { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call someTestOperationValidateBeforeCall(String pathParam, TestRequest testRequest, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'pathParam' is set if (pathParam == null) { throw new ApiException(\\"Missing the required parameter 'pathParam' when calling someTestOperation(Async)\\"); } - + // verify the required parameter 'testRequest' is set if (testRequest == null) { throw new ApiException(\\"Missing the required parameter 'testRequest' when calling someTestOperation(Async)\\"); } - - okhttp3.Call localVarCall = someTestOperationCall(pathParam, testRequest, _callback); - return localVarCall; + return someTestOperationCall(pathParam, testRequest, _callback); } @@ -6267,8 +6338,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -6285,6 +6354,7 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -6301,7 +6371,7 @@ public class ApiError { @SerializedName(SERIALIZED_NAME_ERROR_MESSAGE) private String errorMessage; - public ApiError() { + public ApiError() { } public ApiError errorMessage(String errorMessage) { @@ -6315,7 +6385,6 @@ public class ApiError { * @return errorMessage **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = \\"\\") public String getErrorMessage() { return errorMessage; @@ -6387,9 +6456,7 @@ public class ApiError { */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj == null) { - if (ApiError.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields + if (!ApiError.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null throw new IllegalArgumentException(String.format(\\"The required field(s) %s in ApiError is not found in the empty JSON string\\", ApiError.openapiRequiredFields.toString())); } } @@ -6408,7 +6475,7 @@ public class ApiError { throw new IllegalArgumentException(String.format(\\"The required field \`%s\` is not found in the JSON string: %s\\", requiredField, jsonObj.toString())); } } - if (jsonObj.get(\\"errorMessage\\") != null && !jsonObj.get(\\"errorMessage\\").isJsonPrimitive()) { + if (!jsonObj.get(\\"errorMessage\\").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(\\"Expected the field \`errorMessage\` to be a primitive type in the JSON string but got \`%s\`\\", jsonObj.get(\\"errorMessage\\").toString())); } } @@ -6486,8 +6553,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.math.BigDecimal; @@ -6505,6 +6570,7 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -6521,7 +6587,7 @@ public class TestRequest { @SerializedName(SERIALIZED_NAME_MY_INPUT) private BigDecimal myInput; - public TestRequest() { + public TestRequest() { } public TestRequest myInput(BigDecimal myInput) { @@ -6535,7 +6601,6 @@ public class TestRequest { * @return myInput **/ @javax.annotation.Nullable - @ApiModelProperty(value = \\"\\") public BigDecimal getMyInput() { return myInput; @@ -6606,9 +6671,7 @@ public class TestRequest { */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj == null) { - if (TestRequest.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields + if (!TestRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null throw new IllegalArgumentException(String.format(\\"The required field(s) %s in TestRequest is not found in the empty JSON string\\", TestRequest.openapiRequiredFields.toString())); } } @@ -6695,8 +6758,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -6716,6 +6777,7 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -6732,7 +6794,7 @@ public class TestResponse { @SerializedName(SERIALIZED_NAME_MESSAGES) private List messages = new ArrayList<>(); - public TestResponse() { + public TestResponse() { } public TestResponse messages(List messages) { @@ -6751,7 +6813,6 @@ public class TestResponse { * @return messages **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = \\"\\") public List getMessages() { return messages; @@ -6823,9 +6884,7 @@ public class TestResponse { */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj == null) { - if (TestResponse.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields + if (!TestResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null throw new IllegalArgumentException(String.format(\\"The required field(s) %s in TestResponse is not found in the empty JSON string\\", TestResponse.openapiRequiredFields.toString())); } } @@ -6844,18 +6903,16 @@ public class TestResponse { throw new IllegalArgumentException(String.format(\\"The required field \`%s\` is not found in the JSON string: %s\\", requiredField, jsonObj.toString())); } } - JsonArray jsonArraymessages = jsonObj.getAsJsonArray(\\"messages\\"); - if (jsonArraymessages != null) { - // ensure the json data is an array - if (!jsonObj.get(\\"messages\\").isJsonArray()) { - throw new IllegalArgumentException(String.format(\\"Expected the field \`messages\` to be an array in the JSON string but got \`%s\`\\", jsonObj.get(\\"messages\\").toString())); - } - - // validate the optional field \`messages\` (array) - for (int i = 0; i < jsonArraymessages.size(); i++) { - TestResponseMessagesInner.validateJsonObject(jsonArraymessages.get(i).getAsJsonObject()); - }; + // ensure the json data is an array + if (!jsonObj.get(\\"messages\\").isJsonArray()) { + throw new IllegalArgumentException(String.format(\\"Expected the field \`messages\` to be an array in the JSON string but got \`%s\`\\", jsonObj.get(\\"messages\\").toString())); } + + JsonArray jsonArraymessages = jsonObj.getAsJsonArray(\\"messages\\"); + // validate the required field \`messages\` (array) + for (int i = 0; i < jsonArraymessages.size(); i++) { + TestResponseMessagesInner.validateJsonObject(jsonArraymessages.get(i).getAsJsonObject()); + }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -6931,8 +6988,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -6949,6 +7004,7 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -6969,7 +7025,7 @@ public class TestResponseMessagesInner { @SerializedName(SERIALIZED_NAME_ID) private Integer id; - public TestResponseMessagesInner() { + public TestResponseMessagesInner() { } public TestResponseMessagesInner message(String message) { @@ -6983,7 +7039,6 @@ public class TestResponseMessagesInner { * @return message **/ @javax.annotation.Nullable - @ApiModelProperty(value = \\"\\") public String getMessage() { return message; @@ -7006,7 +7061,6 @@ public class TestResponseMessagesInner { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = \\"\\") public Integer getId() { return id; @@ -7081,9 +7135,7 @@ public class TestResponseMessagesInner { */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj == null) { - if (TestResponseMessagesInner.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields + if (!TestResponseMessagesInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null throw new IllegalArgumentException(String.format(\\"The required field(s) %s in TestResponseMessagesInner is not found in the empty JSON string\\", TestResponseMessagesInner.openapiRequiredFields.toString())); } } @@ -7102,7 +7154,7 @@ public class TestResponseMessagesInner { throw new IllegalArgumentException(String.format(\\"The required field \`%s\` is not found in the JSON string: %s\\", requiredField, jsonObj.toString())); } } - if (jsonObj.get(\\"message\\") != null && !jsonObj.get(\\"message\\").isJsonPrimitive()) { + if ((jsonObj.get(\\"message\\") != null && !jsonObj.get(\\"message\\").isJsonNull()) && !jsonObj.get(\\"message\\").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(\\"Expected the field \`message\` to be a primitive type in the JSON string but got \`%s\`\\", jsonObj.get(\\"message\\").toString())); } } @@ -7237,8 +7289,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -7268,8 +7318,7759 @@ public class ApiErrorTest { } ", - "src/test/java/test/test/client/model/TestRequestTest.java": "/* - * Example API + "src/test/java/test/test/client/model/TestRequestTest.java": "/* + * Example API + * 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. + */ + + +package test.test.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for TestRequest + */ +public class TestRequestTest { + private final TestRequest model = new TestRequest(); + + /** + * Model tests for TestRequest + */ + @Test + public void testTestRequest() { + // TODO: test TestRequest + } + + /** + * Test the property 'myInput' + */ + @Test + public void myInputTest() { + // TODO: test myInput + } + +} +", + "src/test/java/test/test/client/model/TestResponseMessagesInnerTest.java": "/* + * Example API + * 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. + */ + + +package test.test.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for TestResponseMessagesInner + */ +public class TestResponseMessagesInnerTest { + private final TestResponseMessagesInner model = new TestResponseMessagesInner(); + + /** + * Model tests for TestResponseMessagesInner + */ + @Test + public void testTestResponseMessagesInner() { + // TODO: test TestResponseMessagesInner + } + + /** + * Test the property 'message' + */ + @Test + public void messageTest() { + // TODO: test message + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + +} +", + "src/test/java/test/test/client/model/TestResponseTest.java": "/* + * Example API + * 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. + */ + + +package test.test.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import test.test.client.model.TestResponseMessagesInner; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for TestResponse + */ +public class TestResponseTest { + private final TestResponse model = new TestResponse(); + + /** + * Model tests for TestResponse + */ + @Test + public void testTestResponse() { + // TODO: test TestResponse + } + + /** + * Test the property 'messages' + */ + @Test + public void messagesTest() { + // TODO: test messages + } + +} +", +} +`; + +exports[`Generated Java Client Code Unit Tests Multiple Tags 1`] = ` +Object { + ".gitattributes": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +/.gitattributes linguist-generated +/.github/workflows/pull-request-lint.yml linguist-generated +/.gitignore linguist-generated +/.projen/** linguist-generated +/.projen/deps.json linguist-generated +/.projen/files.json linguist-generated +/.projen/tasks.json linguist-generated +/pom.xml linguist-generated", + ".github/workflows/maven.yml": "# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# +# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech) + +name: Java CI with Maven + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + build: + name: Build Multiple Tags Test + runs-on: ubuntu-latest + strategy: + matrix: + java: [ '8' ] + steps: + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: \${{ matrix.java }} + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B package --no-transfer-progress --file pom.xml +", + ".github/workflows/pull-request-lint.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +name: pull-request-lint +on: + pull_request_target: + types: + - labeled + - opened + - synchronize + - reopened + - ready_for_review + - edited +jobs: + validate: + name: Validate PR title + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: amannn/action-semantic-pull-request@v5.0.2 + env: + GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + with: + types: |- + feat + fix + chore + requireScope: false +", + ".gitignore": "*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# exclude jar for gradle wrapper +!gradle/wrapper/*.jar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build +", + ".openapi-generator-ignore": "# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md +", + ".openapi-generator/FILES": ".github/workflows/maven.yml +.gitignore +.openapi-generator-ignore +.travis.yml +README.md +api/openapi.yaml +build.gradle +build.sbt +docs/DefaultApi.md +docs/Tag1Api.md +docs/Tag2Api.md +git_push.sh +gradle.properties +gradle/wrapper/gradle-wrapper.jar +gradle/wrapper/gradle-wrapper.properties +gradlew +gradlew.bat +pom.xml +settings.gradle +src/main/AndroidManifest.xml +src/main/java/test/test/client/ApiCallback.java +src/main/java/test/test/client/ApiClient.java +src/main/java/test/test/client/ApiException.java +src/main/java/test/test/client/ApiResponse.java +src/main/java/test/test/client/Configuration.java +src/main/java/test/test/client/GzipRequestInterceptor.java +src/main/java/test/test/client/JSON.java +src/main/java/test/test/client/Pair.java +src/main/java/test/test/client/ProgressRequestBody.java +src/main/java/test/test/client/ProgressResponseBody.java +src/main/java/test/test/client/ServerConfiguration.java +src/main/java/test/test/client/ServerVariable.java +src/main/java/test/test/client/StringUtil.java +src/main/java/test/test/client/api/DefaultApi.java +src/main/java/test/test/client/api/DefaultApi/Handlers.java +src/main/java/test/test/client/api/DefaultApi/OperationConfig.java +src/main/java/test/test/client/api/DefaultApi/OperationLookup.java +src/main/java/test/test/client/api/DefaultApi/Operations.java +src/main/java/test/test/client/api/Tag1Api.java +src/main/java/test/test/client/api/Tag2Api.java +src/main/java/test/test/client/auth/ApiKeyAuth.java +src/main/java/test/test/client/auth/Authentication.java +src/main/java/test/test/client/auth/HttpBasicAuth.java +src/main/java/test/test/client/auth/HttpBearerAuth.java +src/main/java/test/test/client/model/AbstractOpenApiSchema.java +src/test/java/test/test/client/api/DefaultApiTest.java +src/test/java/test/test/client/api/Tag1ApiTest.java +src/test/java/test/test/client/api/Tag2ApiTest.java +", + ".openapi-generator/VERSION": "6.3.0", + ".projen/deps.json": Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "dependencies": Array [ + Object { + "metadata": Object { + "configuration": Object { + "source": "1.8", + "target": "1.8", + }, + }, + "name": "org.apache.maven.plugins/maven-compiler-plugin", + "type": "build", + "version": "3.8.1", + }, + Object { + "metadata": Object { + "configuration": Object { + "rules": Array [ + Object { + "requireMavenVersion": Array [ + Object { + "version": "3.6", + }, + ], + }, + ], + }, + "executions": Array [ + Object { + "goals": Array [ + "enforce", + ], + "id": "enforce-maven", + }, + ], + }, + "name": "org.apache.maven.plugins/maven-enforcer-plugin", + "type": "build", + "version": "3.0.0-M3", + }, + Object { + "metadata": Object { + "configuration": Object { + "archive": Object { + "index": true, + "manifest": Object { + "addDefaultImplementationEntries": true, + "addDefaultSpecificationEntries": true, + }, + }, + }, + }, + "name": "org.apache.maven.plugins/maven-jar-plugin", + "type": "build", + "version": "3.2.0", + }, + Object { + "metadata": Object { + "configuration": Object { + "additionalJOptions": Object { + "additionalJOption": Array [ + "-J-XX:+TieredCompilation", + "-J-XX:TieredStopAtLevel=1", + ], + }, + "detectJavaApiLink": false, + "failOnError": false, + "show": "protected", + }, + "executions": Array [ + Object { + "goals": Array [ + "jar", + ], + "id": "attach-javadocs", + }, + ], + }, + "name": "org.apache.maven.plugins/maven-javadoc-plugin", + "type": "build", + "version": "3.2.0", + }, + Object { + "metadata": Object { + "executions": Array [ + Object { + "goals": Array [ + "jar", + ], + "id": "attach-sources", + }, + ], + }, + "name": "org.apache.maven.plugins/maven-source-plugin", + "type": "build", + "version": "3.2.1", + }, + Object { + "name": "org.codehaus.mojo/exec-maven-plugin", + "type": "build", + "version": "3.0.0", + }, + Object { + "name": "io.github.cdklabs/projen", + "type": "test", + "version": "99.99.99", + }, + Object { + "name": "org.junit.jupiter/junit-jupiter-api", + "type": "test", + "version": "5.7.0", + }, + Object { + "name": "org.junit.jupiter/junit-jupiter-engine", + "type": "test", + "version": "5.7.0", + }, + ], + }, + ".projen/files.json": Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "files": Array [ + ".gitattributes", + ".github/workflows/pull-request-lint.yml", + ".gitignore", + ".projen/deps.json", + ".projen/files.json", + ".projen/tasks.json", + "pom.xml", + ], + }, + ".projen/tasks.json": Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "tasks": Object { + "build": Object { + "description": "Full release build", + "name": "build", + "steps": Array [ + Object { + "spawn": "default", + }, + Object { + "spawn": "pre-compile", + }, + Object { + "spawn": "compile", + }, + Object { + "spawn": "post-compile", + }, + Object { + "spawn": "test", + }, + Object { + "spawn": "package", + }, + ], + }, + "clobber": Object { + "condition": "git diff --exit-code > /dev/null", + "description": "hard resets to HEAD of origin and cleans the local repo", + "env": Object { + "BRANCH": "$(git branch --show-current)", + }, + "name": "clobber", + "steps": Array [ + Object { + "exec": "git checkout -b scratch", + "name": "save current HEAD in \\"scratch\\" branch", + }, + Object { + "exec": "git checkout $BRANCH", + }, + Object { + "exec": "git fetch origin", + "name": "fetch latest changes from origin", + }, + Object { + "exec": "git reset --hard origin/$BRANCH", + "name": "hard reset to origin commit", + }, + Object { + "exec": "git clean -fdx", + "name": "clean all untracked files", + }, + Object { + "say": "ready to rock! (unpushed commits are under the \\"scratch\\" branch)", + }, + ], + }, + "compile": Object { + "description": "Only compile", + "name": "compile", + "steps": Array [ + Object { + "exec": "mvn compiler:compile", + }, + ], + }, + "default": Object { + "description": "Synthesize project files", + "name": "default", + "steps": Array [ + Object { + "exec": "mvn compiler:testCompile --quiet", + }, + Object { + "exec": "mvn exec:java --quiet -Dexec.mainClass=projenrc -Dexec.classpathScope=\\"test\\"", + }, + ], + }, + "eject": Object { + "description": "Remove projen from the project", + "env": Object { + "PROJEN_EJECTING": "true", + }, + "name": "eject", + "steps": Array [ + Object { + "spawn": "default", + }, + ], + }, + "package": Object { + "description": "Creates the distribution package", + "env": Object { + "MAVEN_OPTS": "-XX:+TieredCompilation -XX:TieredStopAtLevel=1", + }, + "name": "package", + "steps": Array [ + Object { + "exec": "mkdir -p dist/java", + }, + Object { + "exec": "mvn deploy -D=altDeploymentRepository=local::default::file:///$PWD/dist/java", + }, + ], + }, + "post-compile": Object { + "description": "Runs after successful compilation", + "name": "post-compile", + }, + "pre-compile": Object { + "description": "Prepare the project for compilation", + "name": "pre-compile", + }, + "test": Object { + "description": "Run tests", + "name": "test", + "steps": Array [ + Object { + "exec": "mvn test", + }, + ], + }, + }, + }, + ".travis.yml": "# +# Generated by OpenAPI Generator: https://openapi-generator.tech +# +# Ref: https://docs.travis-ci.com/user/languages/java/ +# +language: java +jdk: + - openjdk12 + - openjdk11 + - openjdk10 + - openjdk9 + - openjdk8 +before_install: + # ensure gradlew has proper permission + - chmod a+x ./gradlew +script: + # test using maven + #- mvn test + # test using gradle + - gradle test + # test using sbt + # - sbt test +", + "README.md": "# com.aws.pdk.test + +Multiple Tags Test +- API version: 1.0.0 + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + + +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* + + +## Requirements + +Building the API client library requires: +1. Java 1.8+ +2. Maven (3.8.3+)/Gradle (7.2+) + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +\`\`\`shell +mvn clean install +\`\`\` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +\`\`\`shell +mvn clean deploy +\`\`\` + +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +\`\`\`xml + + test + com.aws.pdk.test + 1.0.0 + compile + +\`\`\` + +### Gradle users + +Add this dependency to your project's build file: + +\`\`\`groovy + repositories { + mavenCentral() // Needed if the 'com.aws.pdk.test' jar has been published to maven central. + mavenLocal() // Needed if the 'com.aws.pdk.test' jar has been published to the local maven repo. + } + + dependencies { + implementation \\"test:com.aws.pdk.test:1.0.0\\" + } +\`\`\` + +### Others + +At first generate the JAR by executing: + +\`\`\`shell +mvn clean package +\`\`\` + +Then manually install the following JARs: + +* \`target/com.aws.pdk.test-1.0.0.jar\` +* \`target/lib/*.jar\` + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +\`\`\`java + +// Import classes: +import test.test.client.ApiClient; +import test.test.client.ApiException; +import test.test.client.Configuration; +import test.test.client.models.*; +import test.test.client.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath(\\"http://localhost\\"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + apiInstance.neither() + .execute(); + } catch (ApiException e) { + System.err.println(\\"Exception when calling DefaultApi#neither\\"); + System.err.println(\\"Status code: \\" + e.getCode()); + System.err.println(\\"Reason: \\" + e.getResponseBody()); + System.err.println(\\"Response headers: \\" + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} + +\`\`\` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*DefaultApi* | [**neither**](docs/DefaultApi.md#neither) | **GET** /neither | +*Tag1Api* | [**both**](docs/Tag1Api.md#both) | **GET** /both | +*Tag1Api* | [**tag1**](docs/Tag1Api.md#tag1) | **GET** /tag1 | +*Tag2Api* | [**tag2**](docs/Tag2Api.md#tag2) | **GET** /tag2 | + + +## Documentation for Models + + + +## Documentation for Authorization + +All endpoints do not require authorization. +Authentication schemes defined for the API: + +## Recommendation + +It's recommended to create an instance of \`ApiClient\` per thread in a multithreaded environment to avoid any potential issues. + +## Author + + + +", + "api/openapi.yaml": "openapi: 3.0.3 +info: + title: Multiple Tags Test + version: 1.0.0 +servers: +- url: / +paths: + /tag1: + get: + operationId: tag1 + responses: + \\"200\\": + description: Ok + tags: + - tag1 + x-accepts: application/json + /tag2: + get: + operationId: tag2 + responses: + \\"200\\": + description: Ok + tags: + - tag2 + x-accepts: application/json + /both: + get: + operationId: both + responses: + \\"200\\": + description: Ok + tags: + - tag1 + x-accepts: application/json + /neither: + get: + operationId: neither + responses: + \\"200\\": + description: Ok + x-accepts: application/json +components: + schemas: {} + +", + "build.gradle": "apply plugin: 'idea' +apply plugin: 'eclipse' +apply plugin: 'java' +apply plugin: 'com.diffplug.spotless' + +group = 'test' +version = '1.0.0' + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' + } +} + +repositories { + mavenCentral() +} +sourceSets { + main.java.srcDirs = ['src/main/java'] +} + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 25 + buildToolsVersion '25.0.2' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 25 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = \\"\${project.name}-\${variant.baseName}-\${version}.aar\\" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + + dependencies { + provided \\"jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version\\" + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create \\"jar\${variant.name.capitalize()}\\", Jar + task.description = \\"Create jar artifact for \${variant.name}\\" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDir + task.destinationDir = project.file(\\"\${project.buildDir}/outputs/jar\\") + task.archiveName = \\"\${project.name}-\${variant.baseName}-\${version}.jar\\" + artifacts.add('archives', task) + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven-publish' + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + publishing { + publications { + maven(MavenPublication) { + artifactId = 'com.aws.pdk.test' + from components.java + } + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + jakarta_annotation_version = \\"1.3.5\\" +} + +dependencies { + implementation 'io.swagger:swagger-annotations:1.6.8' + implementation \\"com.google.code.findbugs:jsr305:3.0.2\\" + implementation 'com.squareup.okhttp3:okhttp:4.10.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' + implementation 'com.google.code.gson:gson:2.9.1' + implementation 'io.gsonfire:gson-fire:1.8.5' + implementation 'javax.ws.rs:jsr311-api:1.1.1' + implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1' + implementation 'org.openapitools:jackson-databind-nullable:0.2.4' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' + implementation \\"jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version\\" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1' + testImplementation 'org.mockito:mockito-core:3.12.4' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1' +} + +javadoc { + options.tags = [ \\"http.response.details:a:Http Response Details\\" ] +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run \`gradlew spotlessApply\` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the \`check\` task + enforceCheck false + + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply \`misc\` to + target '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // don't need to set target, it is inferred from java + + // apply a specific flavor of google-java-format + googleJavaFormat('1.8').aosp().reflowLongStrings() + + removeUnusedImports() + importOrder() + } +} + +test { + // Enable JUnit 5 (Gradle 4.6+). + useJUnitPlatform() + + // Always run tests, even when nothing changed. + dependsOn 'cleanTest' + + // Show test results. + testLogging { + events \\"passed\\", \\"skipped\\", \\"failed\\" + } + +} +", + "build.sbt": "lazy val root = (project in file(\\".\\")). + settings( + organization := \\"test\\", + name := \\"com.aws.pdk.test\\", + version := \\"1.0.0\\", + scalaVersion := \\"2.11.4\\", + scalacOptions ++= Seq(\\"-feature\\"), + javacOptions in compile ++= Seq(\\"-Xlint:deprecation\\"), + publishArtifact in (Compile, packageDoc) := false, + resolvers += Resolver.mavenLocal, + libraryDependencies ++= Seq( + \\"io.swagger\\" % \\"swagger-annotations\\" % \\"1.6.5\\", + \\"com.squareup.okhttp3\\" % \\"okhttp\\" % \\"4.10.0\\", + \\"com.squareup.okhttp3\\" % \\"logging-interceptor\\" % \\"4.10.0\\", + \\"com.google.code.gson\\" % \\"gson\\" % \\"2.9.1\\", + \\"org.apache.commons\\" % \\"commons-lang3\\" % \\"3.12.0\\", + \\"javax.ws.rs\\" % \\"jsr311-api\\" % \\"1.1.1\\", + \\"javax.ws.rs\\" % \\"javax.ws.rs-api\\" % \\"2.1.1\\", + \\"org.openapitools\\" % \\"jackson-databind-nullable\\" % \\"0.2.4\\", + \\"io.gsonfire\\" % \\"gson-fire\\" % \\"1.8.5\\" % \\"compile\\", + \\"jakarta.annotation\\" % \\"jakarta.annotation-api\\" % \\"1.3.5\\" % \\"compile\\", + \\"com.google.code.findbugs\\" % \\"jsr305\\" % \\"3.0.2\\" % \\"compile\\", + \\"jakarta.annotation\\" % \\"jakarta.annotation-api\\" % \\"1.3.5\\" % \\"compile\\", + \\"org.junit.jupiter\\" % \\"junit-jupiter-api\\" % \\"5.9.1\\" % \\"test\\", + \\"com.novocode\\" % \\"junit-interface\\" % \\"0.10\\" % \\"test\\", + \\"org.mockito\\" % \\"mockito-core\\" % \\"3.12.4\\" % \\"test\\" + ) + ) +", + "docs/DefaultApi.md": "# DefaultApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**neither**](DefaultApi.md#neither) | **GET** /neither | | + + + +# **neither** +> neither().execute(); + + + +### Example +\`\`\`java +// Import classes: +import test.test.client.ApiClient; +import test.test.client.ApiException; +import test.test.client.Configuration; +import test.test.client.models.*; +import test.test.client.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath(\\"http://localhost\\"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + apiInstance.neither() + .execute(); + } catch (ApiException e) { + System.err.println(\\"Exception when calling DefaultApi#neither\\"); + System.err.println(\\"Status code: \\" + e.getCode()); + System.err.println(\\"Reason: \\" + e.getResponseBody()); + System.err.println(\\"Response headers: \\" + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +\`\`\` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Ok | - | + +", + "docs/Tag1Api.md": "# Tag1Api + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**both**](Tag1Api.md#both) | **GET** /both | | +| [**tag1**](Tag1Api.md#tag1) | **GET** /tag1 | | + + + +# **both** +> both().execute(); + + + +### Example +\`\`\`java +// Import classes: +import test.test.client.ApiClient; +import test.test.client.ApiException; +import test.test.client.Configuration; +import test.test.client.models.*; +import test.test.client.api.Tag1Api; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath(\\"http://localhost\\"); + + Tag1Api apiInstance = new Tag1Api(defaultClient); + try { + apiInstance.both() + .execute(); + } catch (ApiException e) { + System.err.println(\\"Exception when calling Tag1Api#both\\"); + System.err.println(\\"Status code: \\" + e.getCode()); + System.err.println(\\"Reason: \\" + e.getResponseBody()); + System.err.println(\\"Response headers: \\" + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +\`\`\` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Ok | - | + + +# **tag1** +> tag1().execute(); + + + +### Example +\`\`\`java +// Import classes: +import test.test.client.ApiClient; +import test.test.client.ApiException; +import test.test.client.Configuration; +import test.test.client.models.*; +import test.test.client.api.Tag1Api; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath(\\"http://localhost\\"); + + Tag1Api apiInstance = new Tag1Api(defaultClient); + try { + apiInstance.tag1() + .execute(); + } catch (ApiException e) { + System.err.println(\\"Exception when calling Tag1Api#tag1\\"); + System.err.println(\\"Status code: \\" + e.getCode()); + System.err.println(\\"Reason: \\" + e.getResponseBody()); + System.err.println(\\"Response headers: \\" + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +\`\`\` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Ok | - | + +", + "docs/Tag2Api.md": "# Tag2Api + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**tag2**](Tag2Api.md#tag2) | **GET** /tag2 | | + + + +# **tag2** +> tag2().execute(); + + + +### Example +\`\`\`java +// Import classes: +import test.test.client.ApiClient; +import test.test.client.ApiException; +import test.test.client.Configuration; +import test.test.client.models.*; +import test.test.client.api.Tag2Api; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath(\\"http://localhost\\"); + + Tag2Api apiInstance = new Tag2Api(defaultClient); + try { + apiInstance.tag2() + .execute(); + } catch (ApiException e) { + System.err.println(\\"Exception when calling Tag2Api#tag2\\"); + System.err.println(\\"Status code: \\" + e.getCode()); + System.err.println(\\"Reason: \\" + e.getResponseBody()); + System.err.println(\\"Response headers: \\" + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +\`\`\` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Ok | - | + +", + "git_push.sh": "#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl \\"minor update\\" \\"gitlab.com\\" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ \\"$git_host\\" = \\"\\" ]; then + git_host=\\"github.com\\" + echo \\"[INFO] No command line input provided. Set \\\\$git_host to $git_host\\" +fi + +if [ \\"$git_user_id\\" = \\"\\" ]; then + git_user_id=\\"GIT_USER_ID\\" + echo \\"[INFO] No command line input provided. Set \\\\$git_user_id to $git_user_id\\" +fi + +if [ \\"$git_repo_id\\" = \\"\\" ]; then + git_repo_id=\\"GIT_REPO_ID\\" + echo \\"[INFO] No command line input provided. Set \\\\$git_repo_id to $git_repo_id\\" +fi + +if [ \\"$release_note\\" = \\"\\" ]; then + release_note=\\"Minor update\\" + echo \\"[INFO] No command line input provided. Set \\\\$release_note to $release_note\\" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m \\"$release_note\\" + +# Sets the new remote +git_remote=$(git remote) +if [ \\"$git_remote\\" = \\"\\" ]; then # git remote not defined + + if [ \\"$GIT_TOKEN\\" = \\"\\" ]; then + echo \\"[INFO] \\\\$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment.\\" + git remote add origin https://\${git_host}/\${git_user_id}/\${git_repo_id}.git + else + git remote add origin https://\${git_user_id}:\\"\${GIT_TOKEN}\\"@\${git_host}/\${git_user_id}/\${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo \\"Git pushing to https://\${git_host}/\${git_user_id}/\${git_repo_id}.git\\" +git push origin master 2>&1 | grep -v 'To https' +", + "gradle.properties": "# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). +# To include other gradle properties as part of the code generation process, please use the \`gradleProperties\` option. +# +# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties +# For example, uncomment below to build for Android +#target = android +", + "gradle/wrapper/gradle-wrapper.jar": "PK +A META-INF/PK +Am�>=@?META-INF/MANIFEST.MF�M��LK-.� +K-*��ϳR0�3����-�I�M�+I, +�d��Z)�%��*�%��r�rPK +Aorg/PK +A org/gradle/PK +Aorg/gradle/wrapper/PK +A�%Ӧ�/org/gradle/wrapper/BootstrapMainStarter$1.class�R�n�@=Ӹu1���Ey�@_Iik�6�U�@.,Ru��L�!��G� �6 ���(ı ]t1ss�չ���_�x��󸳈��ᾏM|4�i��s�Z�}.���k�ތ�=e�d/c���Υ�ei�0�c� �=<�O���b��+7.P���m�B%����M� +�-�wźl�6i<�Z2�93�����#��ұw�ںl +h�������x8F��E��v~�ė�9�P%p�w8�.�R3�S� ѵ��Ac�+j�g�QEoN Sz��B�z������j�\\\\�:����� +zQ^��oPK +Ai,�$ +-org/gradle/wrapper/BootstrapMainStarter.class�V�SW�sٰ,�1*���BI/�V�V�(�-m��.�!�nv�f��jﭽ<���� �%�2�ӗv����;�IIb���ٳ���]7�>��1���IF2^� C��0%c���A�0#aVF �d\\\\�{2�Ǽ�d\\\\�Uq�BNP��p]�R2\\"�!c7%|؉^|$A aQ�ʋ� .aI�~ ���ee�4��1�r����tSwN3��+ ��U� �U�䳕�\\"��E�(a��k����{��w�u��T-��.�Z��黶�����9�r���h��u4���8C�,� ���-펖64���:�n�=�n�/�w�hv�<�l#� {.'�a�nVf��ӚM����U� +[��'b��0��^�SXB�D�]Î�.I���,[�X��͗ �w��$w7'nm���H��SçI��r��=���btr6���+�n�e ��:K�YP���_�_�%u��P�-q +i��g���M�-{�\\\\f����I�jW˔0�\`� +N���V8s��K�� �b��� +ʇ���2�_t+�c�O����f�\\\\�ɧ�X�C��Cϖ�K����� + ���9%�9 +,�H�X� +ʩ���; +�c��|�O��}�.�w��Tk�)��3|N�*Z�R�RU_�K_�k�z�3�U梾 +��\`\\\\�4�T �[�၂����l����#��+*0�>�i�X +��i�FZ$K�]�h�O&�������Vo����FW���c-�M��D�qh�ƛ�:U�T��T����;#R�Nv���R�zH$['tk=��e��&ś�o����h�8�6�ls�ܕ���P�=��֣ +�e�d�,�X��: �׶�\`�Զ�l\\"�z�ϼ���N�E�/��w�ۼ�-j=𒶨���y1/ [�\\\\�f �U�e��v��S/7,��xBY|��͙ZI,<�J��G�x��&����[������ +�_� +Ct]b :OI ӓa�$E��$��>¶�C��w�\\\\�����o4�� +Hn\\"�#RG�w� +��Nb(Utm�{��ۣ�*z����*�c�h ���#9_xW���c�h�yG�}�ը�/��C��C�A����S�s/A݇���~8�#� E�R�7q%��B��# +ܤ@-8q;Dv�{K�0�*���G����c�M%�8N����M����UK��;I�1�D�� �%Ğↄ���DvN��ަ�D�����g���y|��px���#U��c���������U��]����@�}���i�P8�T�(�j�@� �1*B��� �qg)�ԗ���_:#Bu�}ә�#�z���qF=�~t +8�ɹ7��s�����'��+��Do4��ҌH�5ɜm�9��f�� W.����&�a�@��[&�x;ra�c\\"� i.�4p��C��*�3t<������̪ϗ���)(g���,Q�\`8���1o�u<^��{_T��W�^�Ŋ�ժ�{�_n����v��<���� �o�!<ꕉks�vŕ�҂�g��C+-�ĝY���}1,�U��1q�ל\`�� Vޥq��ժ��s�:���h�庯�V]�nE�ZS��|�g\\\\d�M�R���e��!���!Z�\\\\J�[ �d'̭�2c�J�&�r]qRru�J�+���8 �S�Xm����ٚ��Mx����o��r\`{.�h��-��g�T^*wS��٢ߡ��d���l�2��gPZ��U m8l�����) �A�X�F�� ���y����k�50'=�ұ�A��Zu��3�57��ĶS\\"�x����n�\\\\7�!C�T�D��M-�%:���ho-%+Ա��B�fuN�I�Q{�E�qM�%���帨v���>E���[��[�NMLݠʧ�77PPb�d�15�/N�nj3����RZl�1�eShK���|^���dS�:83��m���1t��Ȧ�1$���0��p��1��@����:X� +���������M� +:��)�4�G��!�Lx���G/���6�p��I�ͩ7�x�#B_\`����8���w0�=m�u�d��C�C-��\`�I���ˡ����d�)V�\`���.�_ �7R�;!����a��إ�3�m��KH)v#�#oH��վ����VZ��N�I�r.n��{��7��!=���IbN����7\`����h +a.����yD���}�����2^@�#G��e! ��YY�c�J�\\"#��#K��xY&�-/�D15��4%���%V���k�T��D������%�|� +�@�ۥ��l�ܧ�g�h ��Ј��|/�7/]>(�B�_PK +A���ۡ~4org/gradle/wrapper/Download$ProxyAuthenticator.class�U�sSE��M�Mn74�J�X�1I�$E��E���\`�a���ۛ�����xsc�?�3:���8>� �8�:>�W����۴���;��9��s���9����~p%G1�ᴁ>���3Q�����q���u�3U�(>�༚/t�\\"&t\\\\������zp�@+o�踪�C��nU�y����seO�l���D�\\"�ܤ��خ(���X�y��TGdz�!\\\\pK���h9r����ĚM+��k +{Ix���a��z�͉��.�2��z ���H�\`�jU&����^wY��d��z��=�uN��Ż�k�s���Db�wg[%���)��}�r���wM�f��Ū��c�0��� W�2\\\\��_� Gz�{y5�2�8�\`̻5ϔW,�tlg+�2�x +�9��_IE�)���� s�Xбȱ��:np,�&C_{�j�]�� +V��n��+�[�q�!�n�p8��+(���!���59N\\"ɐ���pt������L2�R��8uӜ��&�d��YQ����j9$ق��$_�phvn��2é���%Q�8W���h�P�Yg�Ve��{w�m~�KTa��ZM��A����k�e��~�F!r3��{��h�����4U��)U��\\"�άݕ��ⰱD�na]x�'6�aJ�W +�����RH/a���>z�Y<�nI!h�RQ'�N��4�����2[}K���<�4�@6po�V����/ia�k�:����7�H�C/f������.o���;�i�#�#k�=SÿblX�6=��G�\\"�<�Z޳��J�DI�8^I �\`�+�Xv�Bx��m%�$��,�%��{X +�,�t�����9�@�- {�lt�鴝)3̾vh����'Y��I��|�}��{���s�_��s/�*�Q)��x�?�<���h~���x�Ex�q���~M���c4��Ia���KO�����,�R�,�Л���ռB45 +ת\\\\��\\\\�\\"񯂠7z�u�P�^��E�e��+��CW�*�ŗ/ͥ*7��CHjV�2���i���R4�D�*�6��+ܮ�m�f��U*wx(�A�7��I�NA�f���uܣ�f����ܫpH��T�Wy�B'���y@��B���Qx��ת�K��T�U�-t��U6TRyX��#*�Qy�XUxT���Ōd[TO��ӹ�!=5���Ǣq=�9N�Tg$e\`d�t�ິ9b��Ƞn�A,����ݳ�{����P��l�{�}zcT� +7��d$6��T���L=fnգihg��o��޻+����AQ51����sUo{(�����cЮ������;�� v������ +vvC�Y���L���u�20����aq�����p�pRG���I=�0���r�*w����F2��Z�i��/&�������b�fD�ܲUڌD���JC��n��P����˦v:�2ܗEb����z�����[��m�!T�Č���n#٧����A=�UOF��&:͑v�L�����}�Bh�I�W�zr�y�4S���A|ۭ��B�%� >O\\"O|Uq�0�� ��cLd��\\\\L~�Szv�1���ᔲ����:)M���+ u�݁���7�����g����<����YZI��� #Ҧ�5��j���mݐ�l?� ���7hˍ�7D�������I���.l��H̖=�p- �~\`�H�I,�����F2�G� �2�� +;���CC\\" ��h�Ʊ�h�!���qS�v�as$O�Βx#B9����i����^����Dʎ�P +26=or:�k�}�Q#�6sʃρq.�p����H�0���b�$�*f���I%�����u��6N+�O�� +�1G�Oq̊��?��:3�:���*x�UOE�\\"aEQ�O7���g07x�ׂ�!;m��2֬n� +�d���H�-V7+� +�Z��2̑8\\\\� �/i E�[�5~͐�Y^�& ����\`fA��'ٮ'��57�+�B�qm�[� +�yy+�]�SN�e�ȕH���n�9K�_�[�ǖ���*�& t<��� +��p\`�S]T�Gж����x��]�+'�r4w�+� ��U� ���x��4%�j|��؀�_�$�b����▧�}�k�¯j�����m��D�7������E +S@P4�6��� +�uS7qcn�n�V 0-�Zq7���P+b�T\`���o�T 7�t\\"�6�h�\`�v��>+4�д�MU!q�]V����m�N4쳫�f��jPn +G')J<�\`)zd]֍�KS�KS�ꥩf�E^W��;HWE2Ip}��y�LIr%�e(-ei����>��#�v:�rM���t�o<�9,�Ǟ�: ��7���^Ss�� +�'�8 � _����E����7a��Š�� ��SI5�3PU{�p�V:�����|l�]9&���ܕ� +]7��j��N;�;�z|I����)E�o�?{\\\\��cXXaYu�n~��W��&���N\\"i��<)ôo���;b��!�'A�@[����{�=�7I*.3.1���>)>����������������\`�̂����5�O��g����6>��.�Xn˳k8�W�zH�z8G�{�߼<����sb3� ������GW��V1�(Y9U��(l��ߢ�������y��NQ�;@R��8���N��@��>{�cb�F!۵?��F��4Ai3��� �#F]��xJ<��d ����fߞ��� ���53c!�)��J����!j��~G<*�I����tJ��Lh���hj +���n)+���d��$�قvAu�Og��0��-n�Gx/��0l��|e�5;��ɗ2��=���\`�Hl_|/�wic�;�, �zД��,vB�ˠE�m3�N�b�5��'Gus�VE���n�� b��<�[���Q }��m���0Ɵ� +�O�?��g �>�TE�'^��{��ŃS~�v�ݒ��п����K�� 79�-����Tr�c�|F2߇փ/�E4�V����X��=(�ZT.�g� +�ȞP���x����؁�X�y�\\\\c��ɐr�T����T���K����?I��Z��,�3x�%��z�����ę�c�锚V����ZR�ZJ��&j�nj�Z��RZF_���-�k�u|U�oH�<\\"%��\\\\��5w��\\\\9M>��*��� �B�[#��T\\"�� ,*�pX��K�Y>xBz�I�08� > �������TYS�|5~�q�]�w'��9�uc4�8U�m�p�C�|H%j� ��R�nZGs�(i�崞j�]���#綺���$NJd�t�� :eO��%ͣ��w�(.�,���S���&kϊ�g�}�O������rt���i�@ +���N�9��%7�E����S*mm��V�Q��E^P�M�l���C�,���� ���F*0 \`Kp��-98���� +��ҳXy\\\\nƴ�Lv3�XQ��mws���������t��8-��K�hY�ߝ��MΚZ�s���M�� �*�ryE���o�ߙ��&We5=�6�bt�O�Zo��2�˯fh���Ғ�i� Z���qZ=�x�֜���-=���V��oYU�Z;Zz�C�a�s��h��k����ZЪ�'�R7�WsK3�tt�ALU��3t��u�T�+C�ן��� ���&El8NW\\"l��Z3�&η�׎^�6��1��TSyq!��/?� ,>�ަ��S|��}�g˯�x%� +�\\\\�i1�D@�殣U�#�w׃�0�m4��P\\"4_���n�(�f�N�gI�Y +>5�{���H����f� �sd��� �#�Mn�Et�G7�2:�5t+7�m��V\`�>\`c��)�9M'� �\\\\Kρ���h=��K�� ��!h�\\"ze8�:����n���GH�b=��Y,� ���r@�׺��^A���@�@��w�;����S�C��z]�7zS��d +;��L\\\\,�.����JQ>�� ��\`��)V芰BoO Uc�����a{�E�*~wig��\`g���ǩc%$�h6�g~DM��O����-���1 +���@�\\\\�mn���;��E�?�~�~$�����+︉u�K��<���� RdK +���?���믅N��i2 �! �|Wg�g1SS?Fۭ�A:�̀� P�(����V��@w9��d�m�%��\\\\�j�?@J���#�ƅ�0֯� ����s5�ޥ[��(6��̶#C�t��vf�Z�.� t]���:�n1tb<���C 69��F���\\\\~�߅Ic�Q����^��1��+VF W��\\\\���)�5*2&�U\\"��8��z ���j\`BH���|��T�K�������-8�H��^�������'�Ѐ��S����G�sxp6�h�����%z�H4���ȑ���H�↉K�O诡��p-�L\`{��1�\\"�L=� IŒ�!�XH�S8�MVǘ���D�Ƴ���t.��BA�rmMJ�[:�],�!�����4�v��9���������O�Ī.r%��J[��M DŽ�,��]���8��kߟ_�PU:�]�3a���G�����\\\\�^�&a�t\\"-�E�eY����˛�8\\\\3��K tЎBN��k؁�PK +A!9|�� 3org/gradle/wrapper/ExclusiveFileAccessManager.class�W�sW�Y�ګu|i�V�MNZ*;��J�lB�N�K�Ǝ[��t-���v�j��S�B[(���P\`x� 3�L�$x����0� �}�0��+9�%L=��s��ݿ����O�����t<�gZ��Y��jxNG_�pNGϨ×� �x^mME�SKA-E�H +�1�� ::\`��vI�b3lIŞDIG��qu���fxJ_�~O��c�u,�J ������ +_��5���ɡ� #��� SgGF�� +t�_2/�Y�t�S�g9���C�S�Mǟ1��h�t��DE@�v�]��;��.��\\"�,�� �2�|��@t�-R�m�r�jiNz��-�=�\`�3�g�s��,jɎ��|v�3���.yf�,���]�X��e��BAV*�c�K���̀ 0� �ܬ��OU߲��)T=O:~vȴme��{]ԓs�d�W�䕲�-3�Q�d��E��!�C���q�] 0�E�(��;&f�*2�B5���?��^����}��虫\\\\j�L����C���l��tGuZ��5�[\\" +�Mn,�r�Q�������t�1��)�,,N��@L��5|C�75|K@g�dٷ�'�hʚwL��Q���tnk�}�2�ts��ҟ&J',�VXj�t��%syN�nE>]��o3��;6���lK�q�oF3�V�B�����>%l�W +�!�8$\`��� ������Dղ��3�\\"�x ���D]A��مE�U +��W����x���c�L�Q��V$��Cn�.��O#�&��A7zx� �N5@��T3��(����z��Y�4�}� +��] ҳ�4�?�E�vqݏ�<̏ ����L����N�p�8>K.���1��Dg�[A|�4n�kh�Lp�����S���ES�v\\\\�c�����~]+蘭�vvR���5dw�������=�#r�<��\\\\K��T�����8���lo�7�\`.��Ր��S� +W����ĮT� U4]����~�T��7��6���v����7�BZ ��H� +ҫ@'�c ���Klϓ��3�1�����c�����DQDDwp>���P�z�p}���@8B gmγ*& _$W�� +��+�k��r�}�F�A?~��(��AZ��8�����:�ư�q���8� + ӛ�\\"��؅Q�c��?� z5)��qj��sDP�h� h��F�9҈����u�>�c��~��iMȈvz5�HM���� ��� ��$?b�)n�I�P�$)S������ݳ��hѠǧB����<���q���0��.Ҷ���x��d�(���WW���w@�M�߉�߭5S<�� +�a�<��u�.�˟�3��Gh���G�At�=��dl�٦@]�������ys����:�m��O� +� ���8x4�?PK +A��,y�-org/gradle/wrapper/GradleUserHomeLookup.class�S�N�@= $v��ԔK +J)$���� E�\`@\\"\\\\�@��-�sc-��g��O�N�QM��} (1����#�j�� R�\`�뛿̀i��m���P/�Q��WM:����;\\"��+) Q�g4����+�{�� �>��ek�\\"�T��R���rx����y*J$��Wp����B?^$ /V��ԏs~�L��UTI�*�B.�Rūp^��U�qɯQ�Z�N��[����*���я7��foQ�Vux��Z�]�;T,���;��ǻT��n�����rx����������U|��0R*F1��\\"R0��#*6ᒊ;pُ+r�G�xX�#��cr��*>�O��S����H�G�H�?�����*��/�����+*v�sw�ki ���n�w��kW���==�]����)�1�LJ�m+j��j�����Ѥ!,������no�ȩN����l��P�P 6�l��#���P�~_�9@m�H�؝�3��XԐF��zt�nE� D*�mpn�rg2ⵡ�$��� � +M�S�Nk��b�v�I��p�|N�A[-2E卭��Zx��Ǵ0͜�-N7J3s��D��^�����}Q����.oV���Bӊ������JT*&�N�u]��6�6�G��> �&�O0�V�>ۘ��R��#�3��PSX���6�p�m�afx��V��+T�hNa�=�'��[}������{ [G�+���\\"� \\\\��jE�GrSh#n�v\\"�J��m�\\"в +��R5h!R��q+m��d� n�������8�Y5w�f� �k�:˯�L8w�����o�����T��N�JU�M;��dP�(Ka�ݘ�X,';R�f��S�X�t�j1�A�����DWi��Q�C7�fSZM�8vRzU����D�ĕ�� <���PK +A����\\"org/gradle/wrapper/IDownload.classE�� +�0 ������ +^�b��* A�{���(����l|J�Tf $_����uX���! ������ai'$|T�:�/� ?&��NJ��@��XaXQ�Г7�&���zD��V��ʙ&���6�X����\`��-��6��L͉�v��eL��Cz~@F�@��Y�%�H����'����)�9~��<~��WxL�����߰��\\"N�i� �av�yܲ���'�; �W��Q�����?�/D\\\\���V+mĪM˩N����jJ�jǢN4 ��55e�-$��|��� +�¤��i�u�MGOhSB�Wt�����%+i/ƌ����F��KL�\\\\г���va:Pљ^hw4*\\\\���kQ���^\\\\)�6jk��������d��Q�|5\\\\$��5g�ʧ��@�y��Њ�p�6\`�&��ƚew�R��r,oI�ښRe��~�멶�\\\\s�n��g�B�s�\`�2Ҏ�Ku��1j4���ZIWU|�WP�1�P��j�Ym�lj 9�49�U�[:��y�c���c)G��ܧ�v���N���45�g�jּyΚ !���BR�g�yq)�P��1.(�e%�O�W�U��N�qM����m�;֚guh�wX� �pg/�����0��aŧM[˦m��i�9�l�H��vX(65���c��� �(�)��X��,J�|��{v���g>B�T᫪���D����T�v�j��t��7��s1\`�t�.U�z���{�̈́�z�e�%ؒ��K)y9X����튢u�,5N V>]���E�#�+�K�%TӗN �>+*�)P�%�Ӄ���M���,r{z7�7��~;�|�n��� Q]]�D]����� ��� �� ����Q��fj����-�V�I@�wĚ�A�O�#=�[\`=e�Y���DY��B�G�7S2�_��� �ӻ�V}\\\\6���T���/z�&pyg��\\"D]թ�XB���~i�'��>H���6��?�e]�G1<� ˧Lh��YQbWfI+�\\"�� �&� ���kX|���!���]ۗ�x+Z��� +�3�N\`�yt���e�%X������tLϚ��pp�}'�;��Ƞ.�z�G?�l�n�yjOඖ@����,d�+��/;m.P�Ƕ�-\\"����>�G=��d�k-��&��ⱶϝ�:�u�<�b7LB��\\"!��1�w1u7�q��Q�Մ�5�����}4$�� �#����; �' ߧ ݏ�#�=I�~�b n�q�؆�]� v����na�G܏=�z�#�'Σ_<����‸�[]L�L��a7��ORN��v?ɮ�^I�~��mFu�5�q�Ӯ����rk?���Y��Ӣ/�A�r +��i���n#O��� ��II�~ ��Hv9B��,��{��%4� ��QA#6? :T���.�\\"n�r8���Jf��dO0%��!�^�a����%\`��F����_7��@�PK +A�gh�|-org/gradle/wrapper/Install$InstallCheck.class��]OA��i�]�l ��T)�� Q���hR���ۡ,,-�m�� +�H4�x�?�xfv�I +m����;�s޳3����\`� đ�a9AaE�2]�Q�㚁�ul0U�W\\\\�~\\"R�#��[N�z��1]8����Į�}^��\`��kUk��9�*���U 櫚�஻s(�c�ք��r�>�v�z�X��V\`�����S�Y!%�M�:�N�BE&�NM�n������]�ns��=G��E��eZ���M �V���Q�ǟ85��a�2���m:Tq� +�㗄�8���-�cH�5�}��Oæ �:ɮ + +����X��%\`k@��h�6$h{dP� o���jgʤ�Woz��e;lUBL������0�4a\`��m�ѱɰ8�#7qK�� �oo�G�n0L��6�� �Q z�\\"HK4KK;4&('w�J�&4��O��Y���Ju�b\\\\�aS�Fs3X��a�&�la�����C�>eQ'��X~�Z~��/mL�J��BcsH� Rl^!3� Ә�L™��f#��'�yN�������� Z�.D��f��&C�,�c��?c�c���� +y1�;��9�ʼna^rH| �d��� +gqo�8:��~{�;��\\\\&N*�b{����2q��9�0�v�>Y���PK +A^�,�C- org/gradle/wrapper/Install.class�Y |T��?'�����\\"! �#�Jؗ@�I ��Z�%yIFf����E[����Ҋ]l�����ME��Z��nv��}�n_[Z�?��L&�C���/��޽�{��9��;O���cD�����\\\\$�Y�L��X���hJ��&�� ��t�gx���H��� +2�N�o��A*���A�&�7i_�qs�Va; n��E���g�,}K���H���4���)o +R=�I�+H?���M���A��/ +�F�Xc#H���Fnp��tJ�Rc3H۹K�� �pD�K��SF�i7OpT��4+��D��A���BN�-*�|���\\"P���A�����q�7~�4���]A��fi�-��k|��� �%���{e����UA����G�������&�)���h����أ^��5R)3�Z׸�n{��5�n��T�}[�斋��m��T�|�q�Q5��5���w�fߐ~q{�M����Mtw�ӌ��]�m�Q���2�IӪiV�X�L�ƣ ��i�aӺ̼�4�:�k� +�9n ���\`�t��#�NE.3�G�f]G��Jm2→�ƍC�I��M$��2]X�:z��&��|��!�i2Ml��͖t�ݴ��$:��Ê�{f�k�D๙�;;�����4ls]$e3�r�\`��á]��eؑD|u���H�Fl\\"��ȟg*?mVШ�[����o��L�qӮپ� $��$�=��e�[�1��QQ}]ޤ��a�y�0��SZy�U�Y���E��P�:�j�]���Ö����e)���[0ّ�¼y�)ɥ�-z� �����tW���\`w=�����x��R�$�)�#mE���M@'��.�m�l��t �s�6œi;�FL����7l��� �����^I\\"�n���=���™�����ݡ���^fZ���| nM$�� Fi=ViW�dp:7?7A��|0�3SV$�������$�?�5�e���zC\\"�M0��lЄG-\\\\3R쵫5�aX�L�*�R��eec;��l-�8 +N0:�UP)L%�V��b�ٗ4;l�S��&�j�O���- ��{$�FOb��Hwܰ�6_x +^c���L��سŀ[L+I�$���A���ܸ*�s�it:�4ew&�v�j�� +fض\\"�F���'َD�g�-VB�r}:u8q�鬱2c��͹�]��Z�ǖV: �瓌w�Ԑ�Ō8�OQ��D���I#���8�1��)+���C�W�iFMI���}@����x��x t�@�����'<��F�����h|�k��{�g�m�?�e\`,�Ak�Ik�@.GH�d�l���(�\\"���_�ί/��KS�Ý 3�'�0�\\\\ۈ��F�d���������.���ه�<�^���_��dX���\`X�����<��Q����'\\"�w +[$±7&������e~�i�5��0��vY���a�>C���?��W\`R��!�R�Ce�p��mi�ˀs;�)����nW����1.3����F,)�C�7b�,(��O ++�{ �����0?��Xh���G���@�:��y4,eS8��ږX.�%aÂh�<t��2��]V\\"��V:%�p*��X8�*��� +��J�ل��T���/;2�e�� +؄�T�8fB���fE��ښ�ۑ��+^$辊Rb8��Y��/)X���E������<}��HL�#�L ��P:�����진��'�@��Y�l��O#�������t��~�{9�r9��9���� �oI��J��E��#�=%ʾ�%Y���=!������/��}���?��Y26�dLPѐHG;U�6F f��pr�:w%�ڰ�i�c�\\"���q���/�O5~Y���u����z��R�_�u� +�u�k�ӫ�;�/�������I�W%��Q�W��y�i��|5��$���㴭�J�:ߌFV3(����G�U�LS�JQ�� �zYS��ns�JA �m�#��TV>�.e�(��ۉ)e���Sٝ�3�;zC1E��VQ9��oe�����\\\\�� ��V;m��+H�����s�@S��� +0�kϮi�p��CN��AA�A�.r�s(?ŝ�(�|��/�k�t�Ӱ��€9_G4�ˆ�3޲r���<2K�;�qvb���QqY�+�����{�eO��|?�(kK��m�:�vn�;��C��cI���.u\\"�/�1�v�������}���or���I�^X�O��X��na_�H�#� �X�mX�x\`��{�F:����h\`d��U�p���Y���E~����KQ�H�+s���~8�Nv�kO%�i۔x�$?^�>'��M�z��j2 8F�Hj]���=�N ��S_6b�I���'�M��4S�\\\\nYT4���\\"n������^#b���a�b3/���%��W���/'d����2Wc2��mV�_k��cn�$En�^9��l8�Tb�ID���ǂ3�Z.������=�@��υNzM!W/�d?�阓��d +x�y����,'焖�E.���~�ʛX��Ys�iݐ���#��u +h�m�: ����e����]^�,�[#o�&��M �l��1��0.n�ٙ����% +�r���=��xhYc.�j�uq�v2�zq��t��r\\"�Q��M��x+��P��9�H. T���Q��t��@{=����v8x�ϭ�Š! +���LO�~��WT!����+��Є�j���N~�s�2LS�\\\\�0�fS)��� +��px��F\\"�$2�z� +ԓ������i�R�4�k+h�&4�Z*� x�\\\\� +y���'�Y�~����hJ[E��UUVR�M}�J�%g9t��*�ZM3h$_����얓s-�D�D>ZE������1�׃�t3}�̀���O�jͤO��O�b�+?�5�w���0����iG)�i���UҌ�r��I��@���[p+ͬ�h�ro��S'�T�y��䬃'~Q=@��^뗇���:��;D�A:���Y�/����n����D�[�_��4�V it���4.䛴p��� �d�t�U~>x�9�n�=r\\"��� �yT�z�2�*F���At.��������!�Xg�Ja�E��7P�Z��vR�S?%�~z�.��&�B�� &-L>K��8!���S&�|��h-��cV\\\\�?���a��/ҝJ�}t���-t>� +.^쾖�D����u)i'�֯�^�J4�W��X���^���5:�/MƻFa>N�4jx�Əp� +f�y<}\\"<�k�~��3�)Eeއ���S�z�*�R�=��B�Sգ�<ЂD�G��k Z8�H&ݣd_̣B�WC�}���u�����â�a��B7(}��9�u)��z: +�����=���a�K_Ƽ�,+saNl7�<�)�ѱ��i.�7�,C�,OaKqTC�TWQ5H�k���Kn�E@�ҝE�4�\`ek��[�|խm@�(\\\\��m!� �|�p������h�n + �[j��_ ��#7����=H�B?�W�W�$�!g�zL�Hy�p-PO_Ua}X%Q�7�k�8=�s|���C� +QW+ii�Z�nM �^R-�<�� �b�mt��b'�t������- '�^���;�� ~������U��¬s�d(����I(�r�n�8<���悜s���0\\" +W����� +�c} ��{r�ŒN���g�Y�؀�J��pl�w���������̓T��[�����5�y����E��9\\\\��u��w���q䠦�~�6� +�m���!ϡ\\\\l)q_��߇y��Hc��!��N�%�\\"r�������Jfף0���*�����Y;� +��9 +�U���䕣��y]�A�ҥ�\\"�Q��,�Sl�2b�g��ϑf���eZL��E\`)�~�9/���)���/�+r~XA�R~Ɠ�?4A�_����@~/ʔ���DҍC�#�A�G�%�h��0y�2ps�&~�JD�*yI@�J\\"��KHVۈ�AJ +��rI���.���=H��� +i�g�f�_k���i�w��n|��ΐO!\\\\�y �#� +���N�v��|5r���-�L�D$��[\\\\���,p�������1�h=O�׀\`ރ/���N�mS��w�砲+�PK +A�:�o4org/gradle/wrapper/Logger.class��ko�\`���Unc��@�&s*]7��11$KH�\`�w�ʓ�����_�O�Fg� ?��x�R�5K���r��w.��??h�G �b���1TP����4w��+ͶU���]����.;\`XxfX���!R9���Ӳ��!�1,�j<8�>?4�d�ck��qǐ{�0�#�b�vtUwx�����Q;�� ��6m�!W���\\\\5���]�1,�)��@�F\\\\�s ��˵w/��'.Hq�ϰ3��:�NW�����fu���-Ce\\"��!���l�U�#�;��m\\"x�*�@o���b�w����=C���j[�$�B#�� +�%q�c���I![3�̔��Jg���X�&��ov�HIFi� � +Q��V�(�Iؔ��)r�� +/�,��*�������ꊧP�*qw(�P�&n�_ݖ7ۛPK +A�\`���8org/gradle/wrapper/PathAssembler$LocalDistribution.class�Q�J�@=������x�+�P��AA(*(��mۥ���M��RP�?J���*�/3sf�̜�}{y���,R����6�.�]�0�U�J.d�a���7<�q�/C��-�IŐޒ�L�� �M�h���ٍ��!W��8l_��:��2~)����+�q7�$u�b2�=Z�d���8b��H�ݐ�Z�Z6J��5ū�no6� +�yRߡ� +SK?�� +~M$_S�|a���Y�WЈ�I�V�~ϒ5�����>��p]�1��_ 1*BՂ�rCT��_q�iX�OL��Z��|-�� +F��d� �S�M>W|+�<�*�>�~0T���u��h + ��Y��&�㙉�B�b��5y]Ka�O���u�F~%���w��-�;� +�VZG���0T\\\\�u��e/�<��x<�6�������O;����5�D\\\\�� �[�v�a�8�����>��~�֓\\"n��0��4ψxV�s!<�~��^�@?f�'\\"^ +�e6_ ��^ �u�Cěn���ri\\\\5-C�ٖ�k���)�XI6M������兹���ə�����lf�����e���*�Z15G�⨀�1]3-Y�咭�8?;snbl����hȅ��\`*Ƥ^f7���TK +���e%o����q]@𔪩�ic۽�φ���E�R5e�.�c^Ε�˹.ʆ�so�o������nS.��5C�T#u^�Vϐe�4�WgQ��K�k��a�IB��Eې�wt�s�|�,X���(��i +( ��MeZf�C +�m�����L�4� jE�L��%�lR�m�&es�,�е�6Ai������\\\\T�բbZ�]'S�ۆj]Oe��&�@�Ņ�r1-@��n�:��W*�>AӁ �9K�_���(: +��_U&�,E3�����@��ЫW�/M�R ��]$\`y�R��7�)x��@�[�7M�����5�?�1m��m#��\\"����F񶄯�> 'q���JH� 񈄇1-aѷ�5����] 2r�vRI�j��~�>��/I���_�l����~�w���1N������=��Ŵ_v���?J��,�/����a]@�îL1Si���,����g�Q��i�C��&e ���:kk�ZV�����R!��Vt��6�jۊ�u3±?��ɸ���nI�'�]c���M�ngo��!6�X��I5��p2J%Uͨ�]��k�:��� +�39n�ۖ���Ÿ+~��BĆv��/��\\\\w�i��t�)�� +���g�U71K���p�޿-Т� +Qs9z��M4'9K�L�DS^Q U����sCi����~�����K��c���kC qWp{�?6�]-hW +�E���iN:X�Ђ����7�iz<�fͽ�2�j�׸ :Z��%�����ل;��jڹ�V�/�i�ˍ�+�q[.�;�<:ta�E�{�1���у�q�Y 4�w�|ntdG���S�w�Oh��fK��gg�!����x�&|�;�O;��4�� ZEA�V��6<�3�c1��X �Bvç0p#���_C O���'jO�7Z�W�5�7жT�D��*:\\"�4��i�����N6}#�|�l�u�dcSp�K=��\` +{���\\"H� �#�C�O����kH:9N���9��8&(�V��>H\\"��.g����2�� ���;C +(��sdɓ�(�&�X��8��¾*��p�t#���K�A7LO�.=�Ћ�a��*�c1Q�w;�z-����G�x�H��z�x�t���6п�'Rj8�u���zvK��tVG>q\\"���!�א���]>�.J}��6�$�38O�m$��1K{�=�y'��:�,8��Bȉ���c��e��%ם��Y�����A ����U1�����9:��e +���Q��u�n|�A�c ������W� ��1{I�X6�Gs�t?�'ד��KU 5��QƠ��DvQNʡqZ�u�x�F{���Ds�9\\\\Z!���];<:�S�T\\"B��o!�-��p}�[�S��)2Be��Tj�s���/�#�(�ct\`���\\\\�:�S���8t����S� +��'�)��h�PK +A����| 0org/gradle/wrapper/SystemPropertiesHandler.class�V�SU�]��!,-� +��-�3��TR����%A(��.a�,�ݸٔ�W�~��L}���Ǚ��2c�W��ڱ��& +$��9��s~��s�ޛ���?��\\"� �Q� ��P0�Oc(xSNޒڔ�i3 +fh@ԏ99�-ż�T,H�;�X�R=.��r����~��{x_���&��c�����r|!:}mn~v�\\":�B�ԚvC �53�;�a&# +㖙u4�Y��9]���aΘ�'Գ(��Vi=g:Ɔ���V��K9#���]Q۶��͔nv�-m��ν�v^g-�*6\`Ja���#Y��\\" GAN� +l�����-|,�����g+[� *�Dŧ�L�縥� |��+|��|+�Xyvy�)��'�1Mn�Bʶ6�w{/(���X,��(~> Wٹ�## I���=���(�D���WF��$v t�$�0;��/���~�*�x�B�D�V�\`� +-n��|/�#�����)�����y�e�Ǥ2FIi��&�^�ʫ,=A��5��ٶ����T�m�M�fRص/}6��-Ʒ�bU �$e�g���RevX�|�3%���_ +๡~�cg5h�O�W�� -a�������.����5�T ���c��O��_� �����{�L����������P;� e���3�y��؆:�J�{�3�P�w�@����y42ES��p�~Gw�\\"03��V�;�L�M\`���q��=��4�����/��Z��>�u����\`i��N�]x�G7Y� κc�A=�#7?������ �I4�lv1�4��$ Ĩn��q��R!9K�M�-�z���9�Bԯr���W�)�5�\\"� �,����9z|�~�_=/����!�~�L�0���8�WI�H�-_���{��M +F1�W�U>�� +�=��������Sp�L<\`��ݖ_b�qW��PK +A�=��?-org/gradle/wrapper/WrapperConfiguration.class��mOA�g����JK�|i� + +\\" HULCߐ-��H����&~*M$&�����3w �e��&3�3�������_���:����a�\`@E�G xL�<�2O�<%������xN�8m��P��k����3��5�� �QO��M��5�)����!�Bw�~�+� ��1��sM�(�/;��0�/�w�^����9���sܰ��� +�n����Z�d,8t|�Z�kZM��l��ONl�ڍ�����iv,.�s�m���ns�� =�N��N8�u� ѽ���q$&�L*A��=HL)���BCO*A4dF r_ +�� s���� +�)%Ƞ 2�)�Ae�E�,�� ��$!���X� ��yw� ��y�%^}9�����3� 2�y~��Oȸ�\`;���)H��^V0�YW��^�а�;98��14���724�3��Ot + K��Nj�-;ޞ�-#;�[��N3����}H�t �e��]�rbb��Aqy1yp�Ȗm�G�C���N�$��*=� +8%g�9ݲ +=/a��z�62��9����u�Ȑ� N�l�=qԤ��1.aC�i���[Z:������k?�̝��\`i�af�Rݘi���z��oX4�֔���r��!v��S�F\`�N3M�-�1�z_arT��Q�5�c���!�2x��ݮ\\\\�)��&* ����ԉ^-�ޫ�cd +{���Z��n�! ]��$E�锞s=�' r|˝��4g�9���yJ��� Y��E� +���n� +ts@�f�J�BU�(E�2��DK����2t!cj�'-BF�Y�&�v����\\\\�v�w�����d�L��m�z���^B<��d�� �)G�Go..?�n.�LƗ�a�6��z5�K�l�q +h�8Y[�#��0H M�(aɨ�-��W +��vМ$����\`Pm��ެ�?}U�b��4F��s�N����V���\\\\;��/T��,P���(�H�dHW)�(�M��5�yb-٫$E;����\\"6� ���v� +o�J�V�;�6w����T �$گ���-�T|ߡ�]�y����I�XjZ]�\\"%��)Y�6�>�6i�5�~��g#�M ��;����{,�5�;����U�kUD� +�u=��*���$$�)�-���^Q��I?dIe ͞P�#��1���F/Q�0��'�i?e6�!#��(莄�1��e�L�%�|�%y��,d��Kܢ\\"�|j��¡�S�Rq�m�5��U�;^�G�Q�˚h�&��}#Y܎I��7w<}�E�A��'�L�QQ�W�M��U�����ό�D��2�� }ʉx>���1COG���)7r��a�W��T��N{�R�ӓ�|88a��������AXTY����oe݂zfu����y������tR��{���:���v��:�Z��|\`G�_8檫x�8󨊣����~̕��7�:��+x��@��-I +�:b�qJ޻q(�Kq6�۷�b��j &�������};dm�?J�p�E����)�@a ڦ��ŕf�hr%��Q���2&��x�g�lL�->lD�����M6�uF�g����ºߏ� +C���!̣B�h�^�G��Ю +�h�ϳ_F��~�;=�U����7Ӿ˳_�0�kZ��c��z8��Ivz���v����0ixUñp�,sϢf���a\\\\���s oе(�C��� B�b�j��J�%���%�@����,,V.�Z�X@3#�8����ꚑ�RM�\`:B���B�N�c�X@� x�e,��^F8���8isO�[�\`I�QfQ?��b^�� �Ϣa��� +�I��t�V9gw��\\"3X�6;�kc�s��9['��_@c�p�� +qvC�,bW/��<�guЁE4n\\"k�����XB���e�(�ۉr�}��NLb�n�����<�� ��pa��Kq��K���0 V�HI�8C��K���?RM��Q%ӿV��tʯ<�Z�0�hn!��{ȣ��9o(g.�nmt��rg���RH�\\"2���� �L��D�r� +�.<�7�^�Mҫh���7�.@�#�}���� \\"��l�%�4�-��p��Xn�Ŷ���%�PG +�2k����Yu� +�2�&\\"[�rۇ����[g��~;/@��M��d�客��T��P, Ia�UOs#�M�\\\\�#\\"t[�f8�80���HyCT�!���Hs�����c��/����օ�T�UY��<��0ý�������������8��*C9����ݻm�ʌ=�HN@N��3XL�̈[�[�\\\\ +mRH # SdL9�\\\\����ťl� +9O��C(�.�H']��T� ��!ٞ ތīS����]��h�DL��yW�!p +5 +���k�N�<��X�zZ*%q3a�0LQwx�|q�,8��x����?��cKQ���.-�.��\\"�c#�Lg�d +�_EXƙ\`-q�-z3Ai̷�D#�7�6������^��=n*����\\"�-����PK +A�e� #gradle-wrapper-classpath.properties+(��JM.)�M/JL�I�M���**�+��M��PK +A)gradle-wrapper-parameter-names.propertiesPK +Aorg/gradle/cli/PK +A��?�<S1org/gradle/cli/AbstractCommandLineConverter.class�T]oA= ���\\"��~C?��R*O��h4!����aY�m\`� C��ߢ/4����2��P���a��9{�s���?�PF�@;:v +D�c@���{xY9y�x��\\\\Yc�fs� ڑ߱V�g{m[�x�KH��[�{ʅ�'�&?��b�N��ӵKV�-��)�%��^�{������m!mQaظ������|�j�U��n���l㌟�R�{N�����}f[�� C�� ���-��k��ږ�=,ȍ��؂ak^���߫�^t�� ֔���-J��_,�/]���c��t�ˡ�+;X���r��C�uVQ CW� u�h�Ca�oܠ������1a�6C���2Qľ�L��K�� +&�!9��a{ Q�23Qu� {�'�M���~rՐ���3|i153 �mn�Devf���߆J����~-C�H�;\\"d�9�����edc� ��Dq�ָSX��\`I�w/!)��:�Fy�7���_�|�@�8_A� #��F��VX! �K\`���R~�;�x��)�>=�N�Rnp���؜�c�h��⟐��ϔ�4=c/�-e��PK +A׃��X� +;org/gradle/cli/AbstractPropertiesCommandLineConverter.class�V[WU�N2��0� H��Ԅ��KK�IQJ�������;L�0f���O��Z��Z_�t������A��}N.i�2Y9��}���;�v���O�6�Q0��e|�\`�|��\`w,�'?�� +��H����\` �=�� +V���>�B��x�����&c��.cC� ��i���?]c���З1-c���i8��\\"qB[׊k�cr�Ɣ�m�e����B��h���Ћfb~��M�V�d8�i� �ޞf����'��$ +F]�p�䙶�0�fv�}-QԬB\\"�9�U ёѻ���E#�0�f���f�[��-�Pv�T�4��V5�%\\\\���X3L�X����QgIW����W]�p��0�?���:���ĒVJFO���MA\`i +Үq�����A�1\\\\W@ +��\\\\�A܊�A)5\\"ɓ�4����8,��F�h�J+g� ^�z��KŽ��a�@7��e<��f͂�y\\"�߾�;D='���+�;��%��,��W��J� /G�d����L�Xg<�m�x# ����x +�*&0.�Ko '�+�A�|g��<ߡo�(\`[��b�*��Sa�����������C���%M�U�4�ܹz��%�LEu|t��g�1qBu�)�� �k$1���� +5����xE;i1g��Yu[s밨��D:2�KZM�u6�?Al��T'�[�'\\\\�L�z ��o�B��E�1]^����.���&�z6�K�Z6<��S+Y�h~�u.�V�8X�b��u���2��i�t�e��d��N�۾��H;�4A��?2/y/���j���~���43�1���ˀ$� ��<�g�yWjFK$���j,� � +�t��D��� �� �'R��k���$G �}/a�N�ƫ֪�j�~�����DH���AR����� ͹?��� +�#�0,_;���iq��9|��)�[A�l �q\\"��0���%�T���q�Զ��9��N����R�7��3�w��o��=\\"\\\\�� � b��j��kD�����Q0����-��#Ku�s�u��Q��Ā�ٿ���c�c�ں)Q��=��[��tx�V�p�2�?�\`�'g[��:��YMᶘ��PK +A}��yGK1org/gradle/cli/CommandLineArgumentException.class���J1�O�3���Zm+���U�V +\\" +��–��i�Ff�̨������$-U�fq�{r�wO�����34K(\`˄mu +� ����=}�^DE��S�E�=.�T}.�m���Q���/ +��&���t��_�� G� \\"�]�8�bl *�b&ҫ�=�\\\\�.��$����rA�^��2�(�d�[�ŀf�&՗V��2S���o�/c�PF� ��?^E��5�.)���-��/��1ttu��yN�N�3y��+:���ԕ;XէƬJ�k�⠌u�0�ʜu�g���;�S�~��tӾ���0w3�*6��M�]�PK +A����g)org/gradle/cli/CommandLineConverter.class�QMK�@}���ԯ�'�\\"4 +F<6� EQ($xߦ�%��vS��<��Q�6�L +]Xv�;����߯o�8w�upJp�L-�6�~/���S���b�f�%�u<� �*D�<.�id���n$�b&לpW'<(a��R�\`�q��Kx��l�r?I�����OF�l��$�j�ήw����vRm_U�%J��������vJQ��?���_��F�%p}�b.�;o���-7ۉZ�3��fSm���i�M�l�g����pl��~Qqk*[9�a��#��PK +ASf +�g&org/gradle/cli/CommandLineOption.class�V[wUݓ��4�^��i�\\\\�\\"iB�����Z.�^����dL��0�p�w������ .�UY�����.���d:�ܤˇ��s�����N��~����&�m8'�|�kE�Zqo �މ�.E� +.�A��A��w�h/�� +iEHzWœ���ª8ɉ�C^ܾ&KFA�-A6�n� +:�����T�֍Ԝf�Jh�ӳ9�.Z��ݕ�c���沩9��s��ü��V������[y^���7�B�*�����f$�Җ�8#!Z /!����e��J��D���Y�/�����j�L+��Zj��RiCO����j.3��YLj�o8��--��ZFB˘����bq��I[��eC�_�73�Haf��˚5/΄�fZ5TKkw��t� �+:3���NU�dz-�������k����j�괚w��(ʸ.!�a��pV�g�)�)�_C���{ +�����c.[$ �k�ҿ�l��'贡�{�RS|~2�v�?����x+��bi����zkN�u#�Y� j>��2�Z��fY�T���R�Q���xu��Wx8R��� E�1�0o���g�m���74���Ӂr_q9��\\\\�WO�w��/j�h��z\\"#�����z�,Zi��.Z��FkP�*؏$}��i��B+ +�c��� +na��]b���ᶂ�1��|(��� 2>R�1>a�ʠSz���5 ���xA�$>U�D��P~�.*8�� +����%>Ä��������;���g������+Z��Ekߌ�M' +g�6-�0 �:� �NV�ϟ=!!�{��LX\`�e2zF�I���3U�\\\\�%�N��e5CC]�Z]AၺmѸYC�Y�b�Z.+���&%�����b �\`��)�s�4 �\\"((��{�j^��<�����Q�*�>\\\\����{�#�������%��N���׃\\\\��&9�I<��x����hz�\`�G4?DKyGN�!$az�Z%��V +a �\\"2�� ��5(,�{����� !�۹��=��V�����$�Ij�H���a�D���/�i;��a� +�������xʐ�d��8$���TŘf�+q�Y�����r�*6�:^��]�%�׸wG\\\\�788ˉ�H��ir\`��v?/'��얪�����c�Gaf�;B'��F��|v�v��rȵ#�x=��zC�8Pc.���}�vr�c���� +JȐ�i1!�h�����]�n��G��S�����������0��� �.�j�5\\"GO���� �����n��J0���.b4��-��Ν�л�n=��w�\\"\`��~�r<�a�s>��)C���0�9y�mj��V!:��|��k��\\"%����*���5&��@TZ�[AkI )����Zb�=N�ʆr2�j��� +�s���噜�(�B\`4JY:TCa��e�c��U���*�b2��v�TzCɘ�gKE�ԷN���R�9�r,m:��BM}�V���{\\"O.6��u1᳠��~�-��g~�hW���Kt/�O�vs���� }�+ +��=�]h��Y��,���l$� ���֊����7�� �4O?�� ��gԻ� +����h;_��!��Ѹwi���P����CEӞEV�h\`l�l �,�[��m'GT&p �DA�n��E����!i�/8<~��[$�\\"���V��8z��b3%���+�>g�*h�/V!r'����e���m3=�:Ir��n w���N�0�!�؊u�2�a����I��PK +A�D��&3org/gradle/cli/CommandLineParser$AfterOptions.class��mOA��{-�r-�� >W�+p��\\"�D�!$M�Fxa��g9������.��D%����2�^�rҒc������ffwn��׷fqۀ�Qi�u�4��h �IS�tL�a�T�z��j�6�Pɓ5�&yյ���XO�l�ե}���G8�]���x��2Crɫ<� +��M[>�.YN�� +w�\\\\:J�I�i0d��m���xB��B�r�卆M�u0r$f����u�~�^����F����+��[.5k՗��-�o0$�����z<A�e�k�ͨ��S +�b���V���g<��?�d��\`�Sm��t\\\\cX>��cg�>�v��@]7|�- ƪ�-+�CG��@�ϔ�0� �j��E7 7�c�k��މW7xؒ�1��f�0�0y�d�8��3��5��?U�Ѷ=� +q~ :5�h�h�k�mq�����_�2w��C^�2 +�\\\\�� +�G@�I]�T�����G�i4gL��,~Ab�T +�4�\\"A;�����\`ȑm���:C�٤��3q�����hb�oPK +A��M�u <org/gradle/cli/CommandLineParser$BeforeFirstSubCommand.class�V�r�T���串�:�I ��I|�sk��iK�^���r�ը���,Ӿ��[��2����x�Hnb�N�0��Ϲ�ٳ���=���_~0��2Nc� +K2��ȑ�!aYF�ø���� +ǪP�&C�u�!��%�6>�1�u���(68 +w��o�z|�a,oٕL�V��zF��5�VS���a�wU���9�^6Lù�ps�_�u +W�ݢ���d�֬m��l4jeݾ���$��-M�n��!�M�$�2 ��-[�a�u��(7m2(�MS�תj���ڢ/�xWCiX;P�BNg, �YtT�)���}����3%l1���T��3,�z�o���Kf�=�H�9� T_1$w�bW5�t�?��f�k��5s$]%���������4C� Y �G��p|�@EYx�.���~H@���]*�[q���r�j��;�;�k�G柮G&��İ�SE��Qɪ���z|q��|�y���p�j���( m�j�a8� +�˔Ww[E���^lq��6v����(=��WN#�#�rN�YS���.8��~��rW��ß��������K�*b�; +Q��\\"Q�iD@�r0�M�[�Ҭ$�?!�H�v����C�Iq����f�.Ɇ��1J�ᮨ�����oZ� }4�{�J��E�F�G��?�3x/�J#����'�Gtr)I�p���g{(EOJ��T)�.>Gd�/�-�G�WZo=sP�#�\`K3�Q��[F�]F�]��pՅ���ڇ�b�Y��h@�~R ���(�!�ijJ3n�����8B�# g��HW���ܱ���a6�:Nx*��9��g\\\\��.{b�� �׹�ڸ��i^E��\`�� N�$��,���S�D���gq����c)�/h�R��PK +A�*�ZM�Forg/gradle/cli/CommandLineParser$CaseInsensitiveStringComparator.class�S]OA=w��P�Rˇ�\\"�UhAx1���ML�ԏ������v��n�����/��\`|������Ek�C���9��{Ng?���&6 �Q)\`�,9�5�=K&�l�fc��*!��|m2��]B�t%a��|�|�ߓzG�y�)����v�V�&��+�\\"�M?�~�\\"u$ۑV~���Q� N���nx\\" %��6m܏�#�nԍ�֛uB�_Є���\\"�[�f)����ְ�m�*����ȧ�H�j�f�p��\\\\�p �ߩLb������s� ��E����\\"L��d'h��@Kӟ0}��1/d� MXE�n���qsYX�'>9|r9�\\\\�=�w��P�5o���y�$L�̑��i�ft�cye��������}������l�y:E����1k-�LY�n3q�2����\\\\�u�M&:���c�#����2���Oȭ���㿈(&�J\`�R�����؁�p6k�0��,���X��\\\\����*w��M/��PK +A|�R��&=org/gradle/cli/CommandLineParser$KnownOptionParserState.class�X�wU��6ͤ�K�*EqD�t��;VkE��E�+. ɐ�3uf҂�HQpCqP�![�>��u�\\\\|���I�\\\\@-V< +���g�Z�Y͓���5ͨ-4Τ�j�ת� +窬��m͵l�� Z�n����pi +S�5꿗�$뻦 +�b^�)��S��t��d%f���sT�CP��\`�g^�� +���t ����H�@�'�؄N�r�\\"#��^h���N�oGQ7AUߑ�t$� �YFRk�|����y�aC�@��g���pP����n'�I�<:\\\\(�=�Ě�p�����,���᝛���a����ұ<��V��8�o�ST�=�G����K��Q� ��~�q�;~�Wq��W�|����\\\\����T���۰kqS� ���'��'Q.ᖿQs�w8�Th���DL)� Gc�M�CG!O �+�m>V6�d�����hd� �F��^��w�����މ&� +a�ࠑ�W�~q���p�N߽̾2BI� +�7���!�?PK +A$ľ���<org/gradle/cli/CommandLineParser$MissingOptionArgState.class��mO�P��w��*��LD�� +�!� ·'�\`0�W�̚�o;��o���B��~?��ܶ�K˒��s~�퟿�~�Œ�r:��'I*(uZG +7�ٌ��q��eМ-�rD��_��K.]S�z�3��B��js�5]���#ņ�u�,n�V��4�\\\\�k�0��#�%�r��w�����[c�U�:�3� WZ� +S��6���9��^��Rzx��Z���s�u-��˲V��;���TJ��?n��I/�GQ��w|�m.�UO��Rn�!�eC�w�&à# ֻ �@��~�+���:0��r��\`��#:L�:՞ͭ�1�𦯉��)�[�PR�2��q\\\\�U�%7�ǖڒ�#63���V��t�20�1,��K�\`<�E�����a�$�e�=y&z��a�� ������io٦ +Sʞx[t���)<�L/gd�핤�=Ij$i�� ��0iOH��*���~\\"�Cj��A�Q���{�I�����gI�/),��9������ ��}k�4������ +�q��Ж��g�2�\`���(L�B�~���e�6n0�)I')B�e���{a�I�㇡�;rL���v�\\\\ +Q_Q�����ӕ;������0��AS�B�e4h��Ρd�v6l�o����_є�� �h8%1�+a��U��' ��PK +ATK>��=org/gradle/cli/CommandLineParser$OptionAwareParserState.class�U�n�@=��q�$�6\\\\�%�)M�K�@)�p)E� E*o��Į��O� x�$ +�J|��Mݒ*A./ޝ���gf퟿��PĽ8ȩ�0*w�Tz���c\\\\�� �*L+(��cVAQ�u���4�ܮ�,�dȖQ/��5̂Ѱ +O�p����C�{i����\\\\����e˶�; ���\`�� +CdթQ�I��h5��xƫ +� ��7*\\\\X����.C�ɶg9���Z��ŵu�6�j���I���,s���]SM��j�%�} �P����녲',��4��!�E]&���8��c$�\${�]p�G�짍���o�R�NK�%�t��i��!���Ә�ЏSnbX���[XP��a � s�����L�f �+��~�a��[��f�:�~���Z�)9h��O�S������ c�s��m�q�r�� |�������F���dU���ԩ��0L�����-=ƽ���_��qk�ޥvr�l0.��ϥF��|���x��!��J�Ӛ�'v�t�!}r�O�Y�Y��,T6�$�a�|i��Z���� �̋dKTT���ȇC�(���<�C�(.��.#��젯�*�&�>Z�7D�!�eSZ2B���#����o��o+5U���c���Cݢ�{�� +B��*^�v�#8G�Ni$�y6���+���1E�8�3$r�]��oPK +A�%�̻�7org/gradle/cli/CommandLineParser$OptionComparator.class�TmO�P~���Q:� +�� � +�2@�.�,Y�d�ďe4��kI��?�/~#���ƨ_�� +N6).]��}�s�=��~��� �E�%d0#����0+bN�U�J\\"E,IHs;�'\\"V8|U�Sk\\"�z6L��7�e�A(;í�i;�����-� V��n�����)��L�!�{䛎]v�G����� Wl�p˖�y!����P�~\`j�2U�6u���y����N_���z\`Q�W�k�H-�T�� ��T|�%|���4y�\`�P?�UK�j�wM���k��w����uz��-�֤��$�/0L���[3��xѪ��M�7-�O�7� �I�R�i�u��;?ڑ~�S��b@�����Z�a��B���h�Ο�\\\\��i���a+6eY�����g��љ{\\"!c /&��q� ����v�a�[�h��ǂZ�0�0 }��m j��]{���a�=�eўB�$�>��P���}�4�s2�|=ѧ��Q*t�e躣K�.@ >rd +���d$S3gH|$%�!z�p'��a����!�x���D�\\"�2{��9��� �O蹀�S�p� �Hs�wnL8�tr��I\\"��!�y�3Ⱥ2GY�v�����>i<2����<l�4!�M�{�n�V���� �� +��#f�dY��\\"�5���>�{}FC��NS��#ZO�q�ϣH�INQ�2(R�8��˦�S�<�i��� +PK +A�fC���8org/gradle/cli/CommandLineParser$OptionParserState.class���JAƿ�Y����4ն֨��JoJ�P����H.��$�:���ى� +}�/�}��3����4�ߙ���Μ�����#�B���F��UB�Xie? +���o�}IXl)-O���4碛pf���D�F��8��K��ή�J�a2i�VX�T���4�Dd�d��Vj�(6��Ȩ����B�]�Q]��AXH5�ƞ�[�����O���&��B�T3k8��N�+q#�D�8j[�tܘ��K�Md�T�̋�W^'��ۄ��d���[�w{H������ӡ�ɯ�m���s��+a�;����@(?^�Y�J�x���\\\\a{�(��$�_��ׇ{���L |�X�uf��fs'�'�8.� ��ygX�u+���e��/;�����������0���:^�eor�[n��}�y?�\\"k�����g�PK +A���E��3org/gradle/cli/CommandLineParser$OptionString.class�T�NA��z��q�ZDQ��G�Qğ kL�&(�[��rx�k�����/$�&>��qv[l�B�����|��������'�9<�E?L�Ĵ�4�B-�0��, +�:4�( 1��m�;�ᮆ{ �����#�<�׬�8t��COЈ���͢���T�ݯ�RXgP+A�aXv}ge���o���L�ͽu�Bo�xˍ�U�� C� �wŠǣȡSk9kV-�Uϱlϵ*A����H񚇑�N�S�?s���?��:幘/t*�-���W�!�h�ϐ��汆 /�Tww~e��Ӭe!�rg�c���DQ�乎�OE��;McBһ���-�!��%��.��\\"�{��N'�M��zz����Y%�B65[�m�~��k�E�T�BZƓq�5�<�]/h����}LѾ�>�����M�c��G��MHx���)����PK +A\`M~U�2org/gradle/cli/CommandLineParser$ParserState.class�S�o�P�N) s���97ս�&ML�f����.а.���vF�'_|����(�-�� A���G����������mdQ��C-��6�xba�B��{�I/zI�4����\\\\�jϓ���d�b�s�� ��?���4iF�^H(�*tU?'��tU�a���v/Pcg���w���9�\`2r�;$u�Ty�P��/�#}��@��3�I8��c�)O�;�B� / ��Z� �����&���Wt��i2���qf�YC!�����z�Pڕh&ߗ�P2��e��g�v�nӁ�$�$T@|�*>A��%��W|�):�T Џ3����_qI�_q3!��Ź�t��^= +x�c @����C��!��:�Z_ e��Y��q�>8YM��H�E�F��w@�@9\\\\\\"��!�v�C��z��1���v񫮥x��&҃�k�$}ˌf��!�u����Tsj]�p9�9�+��1��:�*�4�*4fE�!�������./1Y��� ���?PK +A�=l)&org/gradle/cli/CommandLineParser.class�Yi\`\\\\ő�J��7zz�eٲ=\`l��1���S>K6����Xz�Fψ��8B����\`�\`���d ��M�����Ͳaك=� +!l��~�ޛ�����PwOwUuUu���O�{��Y�T:�j�W5�ױ�h��/>��)��s�3 +���O�� +>ס� y�R�a#��|��|��1�ׄW��%G���ģc�x��S�5��E��]��%_���fF�eu���֤P�t|e�&cu�����q��8&�&���䞬��JO��|7#�P\\"t��M$(�����L8?�=���cq3֔&LM�s�sO��A0�e�AQC(���j]��Z�-um 3f��5i��f� +�≦�m�kG0�JKͶh�̚�dc�u;�13c�M������0�[�1�׬�_ݸ���a��5u�֭X�(�� ^��N���1���U�&��V���QQ[٥=I�Ҩ�]��k +�G���-\\\\�����Fګm�WEc����\`kجn ���V�\\"����E�9:Gw6�v������1�|�yqe�41���P<�-l҉��H(�H�[R�s�,���J��ؽc�[����-���\`,�~;��DG���|�������K�g�lloi���5M%� ��9.b�I+v�����\\"�[�FU��R�o;�R��\`��FN��3#��mL=� ��4�P�%$�l���u�� +* c�Late+�r\\"n���uUC��iظ̀��J���]B\\\\� +k���X5�P�j���:��)B�p(^H�i%����n Z��kn ��ݒ��_�>N���� +��&3A�32g R4��d�� Z�8?l�y�O����m'�ˆf@��h�Ռ%sƞU�u��6��3iʭ +ŕ������%�p77���DL�^a�E��9͚V\\\\�EW +�p� vX8�)��4iFf(M�a��}��.��l?�F�,�N@6�� 7�w�3���§�E�5�F�p J�-���f�n1�R^��:�t[���B�Y��ԙd��3���R÷���M΄A-�V�vm�ϼ�.(S�Y�n�Z�Q_;�S��[Z�x|ڜ�3�K�F�R^�9�fp�U�g �sPY�1O��/ �}��M��X k#���I�Rr ܊[ ܀ +ܬF���D��-� �;��&-���i�{�OP<����1�Mڹ�t���\\\\͐׍ku��;5�nHXv��!]r1%�� � �0��Ґ�t *��1��T]Bح��t��-�씸!��ǐK�2C.�+%���ª2C�!W*�or�\\\\Mx��ղZ�m��U�3W����q�\\\\��lE,�r�Rz���[U���V�3�[r�!7(G�(Wr�|ې��jCn���*��%*��Ų!��wYX�����2�u]�4y��ӇY +<'�k�P͝��%w'�t�3��lu�Y9L�ُC�'�d�R�{23$*� +��0d�\\\\/�!{�^C�/�hr��7��ܟŞkCP���Ɉ: +��\\\\lȃ���nяE��b�\`��*�ƹc�&{�>Vi%��=f ٽ�wb��eic�^�Rĉ^�Éw�w�\`��� �O�F�3<,�dn>g?�_�y2��|�����%� +��z�X�>\\"�Nd1�V�f�Y72�pLb�h1s}���6=�Jq����Ŵ�*��9���DuX�U���ǻ?���}e������[�ւeN(��q�%�B=�:��FsW����z��~�-)u+Z v{���p,�|������{���\`8�E�< �r�_n��۷�C�c^�{[܉բ�z�v� +�46���<[]�k�t6SN��o��;:������ԃ�C���qֻ��[�c��\`���|ݽ��(~�zv��V�7\\\\e���\\"�z����>��L��P_�k���p�6#�+L��h�1I\`�E�4c��/�]A�in��ع��<��hw׆�ڧ0=�՗g3�Nj'\\"�@#y�Yk>nV�0=t�zi��H_�����r3� %?~u�'�\\\\����v��B�� +A� ��7��o}m�h��~�� +�ǡ�W���s� ��_&�%�@,y�����ő�<ހ� M��<�k�����֭�0nGRZ՞�A<[1�Q; hK�&§i13|d�7�L�]$7$�J����A�h5㡘ٚz=�����贞�_��.��q*:��'�����F��&k�m��l�oU}���������w�kr9�r�x���m>�3�y�⼃�����N� �w�n�W�})����m^Y�Ah���O �YL+,�l\\"G�����˱�����7<���7hb>�x�������i��!_p��h���� +9�Q��}(� ���a�\`���F���˜Zoe�ۋ��局����v�����}r��8i7N\\"e�K�{1�����\\\\N�IAU�[���k|6e)�������=�Lg�i��t�E��:���Rt����=(\\"�4R�A~?��(N{�,$��)��>�ȡ��)Y>gGK;��Ȯ�,J͡���%TZX֋rE\\\\ދ +�O�����܍€?i.U�Mj���[�W��\\\\V� ��*�Rv��\\"uG��Y�xm��;��>,�.�����Ӈ�K�֑�l�wlfe/N��oE���'Q����b����Wb#�\`cm3�<� ��؊_�\\"�K��� +����*#\`�x��)h�btH):�Ll�&�evH'�҅.��M��^��Q�~;�9��˸T��7�C\\\\)�5���?�z9�sr��*��h���p?ۻ0��=�Q֜F� {���tw���t�c1~D�����k����U�a����!��t0�F!SE/��w����X��S��'�M��d_ø8�缁羑g���M�'��9����K �(=SX�-,�3��,-N��=��u�S�9�P�i����� +���Q��c\\"���%��p;°��s��\`q��x<����6V�����~,���z*-w�����F�G|��:%f)�XJ�X���BV4[J^ ϑ�^�l��T{���� +��p�����������g�9܅*�+�/#ߒ�Z�JNxy���*���uìR6+�|*,�&����V�U�V} +5^Ƈbi�ҕbY��Ї5������y����\\\\��$h��:4�\\"i��4��h��p�m�7����H����8���T ^��R��x 0�K%��k��A�g�鵓r7s�~��!��o_������ǜ9�\`9����_K_��$��,�+� �J;~);�܆��%�!��My�xw���#){9�%�q�G���2wR�����0 +/r5�{���,�5����q�BH��\\\\����� +�d^p�K��PΓ�7x�Y���+��b�܋7X:y���x�Y絲F园ɯS��-1����8g��O��{zSe� +y�Nv��a��\`�aZ�x��� +5��m��C�d\\"�QL��tL�q:ɛ� +e�c%,3w����]}s����S�}���~e?�2<��_��p媲>lJ��0ݩ�j���A^�i� +uoQ��E������pê8�~?��oS�w/��-�Oijw�g��޶K�/����U��G�y�^�}�B�����,�ZJ��,;����;ɢ����x�b��f9�r���K�a�2�J|ߋs�=ijS�8T�PqhQn���sʃ�YQ�U�@��O�~lm.��I=o�A\`�2/-�����'a*o���}�CӑMs��wō��iV���*,�K�:&U�@�c��Hb�{V5�ky��E=�!��#�&�P�==� k�Oц?�r�]�?1�>g�A���y{8u +c�a�*^����H�*�R��!�V��g��-y�h��.�#�f�N>��_�{EV43$������f�f�N�8�Ѭ����;��l��d�O�� sN����]w�a������i�� +;{���g<�Oaja� v<s�[��G�%.�X\\"���\\"�Q kGOa�X�g\\\\�p�����>�>����.a���.�=������dz����A�#�_�������;q +�e�V)^���?PK +A��>�&org/gradle/cli/ParsedCommandLine.class�Wiwg~F���ċ�%v�TMc[����R����8�S���)-L���T�(����.Ph١li�7 ��\`rX���;��Ɵ�����}g$Kָ1G�����}����.3�ǽ?���.�v�*��\`�!��*��΢ .��bu�f��T���,.+*�W�BM0#h�'��\\".��T=^��a�����}:�|F�kt� ����0^�7�����/�㋸$�__V�0�A�V���Ma� +q������[ +ͼ�1s�#+3��ɥ����/�E;����� +�f2�n-C���#�2�����i�Җ�� �����U0R��Ғ�KMfr�)y��(��Q0r��*T>c�4y�Z�q���%s�H���˶��Y���h������M�-�C#�\\\\�U��08a�~.k ��*��)Cx��K� �)�LAt�\\\\г���kWY�p�#�A͙ +���� FA|���W�ݳw�/뀽�)x����V5KԶx����:ԕ|)���#�wOP�c���c�I(�V��^y���U�6K������bѴ��\\\\j������3Tp�UG(���|�V�Q��H1�M� 7S8�� +�RΊ|{��Y�#۶���nQ/���5^k�Ko�u�O;=F��m,�R���h�q3�5$�bwc�LO�F�ܙm�� +�����L���n\\"�����9m�G7M�h�z*gJw�r�v詔D�ճEc �Y��e�y�K�?�a{���?�՜qZ:��fy���ȌY��c��m5����� + � �^Xd�k�����ޏဂ6��Y��\\"��|P�[x[�w�= +�����1s�=>4�?R�c��f�U�D�O�3��8�*$c�/GW���*�S�.��5�“~�U�n�� +|ɘ�_��=�0�a �4� +WU\\\\�0��~��p�WL�HZϖ�:zy�py�����*��r�K�}j��c���븪�����֒[���v.��2}Ri����c9SV�U�P�P�IΝir+���9�������g�S�� +����Q��Z�y��ۇ��OB�MkI'ƠG�>�� �=�7r���W=¶~��̜�gD��1[�f(O :��6y��P=𸟳J8�J�e������2m�sQ��P0����-^^��Ц5[����y?�A�C�2?Tj�H܆����m�o\\"@1H1t��XG1r�}k�L%װC���Р�h���&�4�o!�� ;��]LHҰe(��=���Z��[]����;7d���?��k'W���o����� �A�؅속=x�5��:I�C�a��b!Z�cx�(D��p1�')�1��a���8���!�N��*�*&T���=t�hT�����_�P;�=�'��X����/����� F���Ι���bX�@�u #Bw�v�p��\\\\�}b�9�û��x?}�d����������T�}HH.���o!���s��y�V�����O��C��I�/�a$�q�a�x�A1c���x��)R_J@{�& (�+�}�?Av��3x��G�� f����97���CTE�B��\\"���]t���F��.�'���ޜ軅؜��t<�õ2�i ��1�i����_3�%����6� +;Aؓ����q��6�A-��V4Rg��Z�l�G� ����o��rN�$�g��dy�E:��+����N:$��̕��ų�xU� �'\\\\�5��B%ǻ6 +Z�3�]^ᜐ��k��>�l�J� +;�k>��e�'*�6z��E�Ge�)��A�<�],;[���S;\\\\��O��r=l8>Y ��߀��^��9ي� ��NL��vcz�ͭ&@S܇��Қg\\\\�H�VvWc�� .��97�{�X�Ř�㰗G�o�� )�ȑ�,�I8�s��Q�HI 0��$Ab�s��9��{�\`_i�*^QUt� + � +���������9%�<'� t�E�B^�K��r�vs?��\`��A�^EAEXP QP +�dȹ�PK +Ay�t�E,org/gradle/cli/ParsedCommandLineOption.class�S]O�@=ݯ�G�e�Pa�eQ���\\"�hHV1Y���awR������l���I�g��N[\`Y$�ә�{�=����?��“4�(��H#�b +���冊�$�4���-L%q[�器+��r��⾊ +[�lpWA��ɶ���������(H��a1��p#-�g���,C/{����9*I� +Kxs +���U�E�J�%a��:w^�u�\\"��]a�*s�<����!�I�d;�n8�jr�b +�s\\\\^]�k5fU%�J��E��V�݅���=Vy������ +j�;*i=z&x�� �V�Q㖧��p6K:�d�)��Kn07T@��U�.� +�Ÿ �v��ICzt��]p�-)k�DN�(� �t]6Mn0�,���� +��(#�Wm��-��o�-�g�v޿��Ѱ��f0��?L'��Z��D��A�K��@�϶*���$����)���M^!�O���+v�i���Q,7_�������Z~����]�սm\\\\�(K? +L�H�.:EЍ8��rZ/PdQ���>��!\\"k��~E쳟}�V�_�*bT�G;-��%����b�X��o�������������\\"��p�(=@&�_���2�w�%��^*��$�A�P�PS��� =1D:��!䉩��If�%�ޱ��n���0�5W(v��b�RD +�$���\\"x�j�2D�ϧ��xr7�k> +��!��V.p�]�.��G��ӱ��D�\\\\��8\\"�y R����PK +A\\\\v�B| :org/gradle/cli/ProjectPropertiesCommandLineConverter.class��KO�@��D|?Pâ���u�#Q�+�$�C;�1m�  �JW&.��(��1�D�,��9��v�o�/���[@yl汕G)��v� +}FHWkw�LS����!�]�nY�7�ZK:̿cJD�����ZRy����s���V�;�H�+-��)���n�kS�#cruLX��gh|��B���j���F��Y���D��Ώ�%�L��%���񎅎*�_���?�ֈ:(\\"�<�ڄbJՍ� ��؊t�f�^*K��� +ߵ� +XU��V����i01�k +���p8��wZ��8T0g�?P�a�Λ�m����=���C +S�s ����| �1\\\\���Z�q-}C�_�J��Eˉ�j��E+ ��w'��PK +A +�8=|�9org/gradle/cli/SystemPropertiesCommandLineConverter.class���J�@��ثm���j�E�5BPą�R/P�~�ӑ$&�B�JW� ��'i�A�Y�3���͜�����l� �\\"l�Y��l�E �<&� d���@���H��g�L��{:r�R�s�:C*X4NĬ����Q� ۴;hZ3a ѽ�G!]��G�v�7S\\"�5eb +o}ɸG�����tFM�z�9��y���~X{()spL\`7e.�KV, +�TXxɢ����fDT�E�G��P�W��Jm�h~���49A�jx��Ѱ +��s�h�� +gԙ�n8��5��]�.F�Ԓ�s�9��Q��΢��*�s�/@�Ug J*�c�e+s��+1� +��$p�����6���/t-�,�;�h-�.�Z +�>k�Z�PK +A �AMETA-INF/PK +Am�>=@?��)META-INF/MANIFEST.MFPK +A�A�org/PK +A �A�org/gradle/PK +A�A�org/gradle/wrapper/PK +A�%Ӧ�/��org/gradle/wrapper/BootstrapMainStarter$1.classPK +Ai,�$ +-��#org/gradle/wrapper/BootstrapMainStarter.classPK +AhQ�}��#���org/gradle/wrapper/Download$1.classPK +Ay�[�4�A��p org/gradle/wrapper/Download$DefaultDownloadProgressListener.classPK +A���ۡ~4��org/gradle/wrapper/Download$ProxyAuthenticator.classPK +A�pO�)�&!���org/gradle/wrapper/Download.classPK +Ay�L���1��^$org/gradle/wrapper/DownloadProgressListener.classPK +A!9|�� 3��N%org/gradle/wrapper/ExclusiveFileAccessManager.classPK +A��,y�-��U,org/gradle/wrapper/GradleUserHomeLookup.classPK +APr��� -*��/org/gradle/wrapper/GradleWrapperMain.classPK +A����\\"�� 9org/gradle/wrapper/IDownload.classPK +A9l�V�\\"���9org/gradle/wrapper/Install$1.classPK +A�gh�|-���Borg/gradle/wrapper/Install$InstallCheck.classPK +A^�,�C- ��SEorg/gradle/wrapper/Install.classPK +A�:�o4��2Zorg/gradle/wrapper/Logger.classPK +A�\`���8���\\\\org/gradle/wrapper/PathAssembler$LocalDistribution.classPK +A��;+&���^org/gradle/wrapper/PathAssembler.classPK +A����| 0�� +forg/gradle/wrapper/SystemPropertiesHandler.classPK +A�=��?-��korg/gradle/wrapper/WrapperConfiguration.classPK +AG�� (��norg/gradle/wrapper/WrapperExecutor.classPK +A�e� #��pwgradle-wrapper-classpath.propertiesPK +A)���wgradle-wrapper-parameter-names.propertiesPK +A�Axorg/gradle/cli/PK +A��?�<S1��Hxorg/gradle/cli/AbstractCommandLineConverter.classPK +A׃��X� +;���zorg/gradle/cli/AbstractPropertiesCommandLineConverter.classPK +A}��yGK1���org/gradle/cli/CommandLineArgumentException.classPK +A����g)���org/gradle/cli/CommandLineConverter.classPK +ASf +�g&��z�org/gradle/cli/CommandLineOption.classPK +A�튯��(����org/gradle/cli/CommandLineParser$1.classPK +A$f{K� ;����org/gradle/cli/CommandLineParser$AfterFirstSubCommand.classPK +A�D��&3��O�org/gradle/cli/CommandLineParser$AfterOptions.classPK +A��M�u <��B�org/gradle/cli/CommandLineParser$BeforeFirstSubCommand.classPK +A�*�ZM�F����org/gradle/cli/CommandLineParser$CaseInsensitiveStringComparator.classPK +A|�R��&=��I�org/gradle/cli/CommandLineParser$KnownOptionParserState.classPK +A$ľ���<��t�org/gradle/cli/CommandLineParser$MissingOptionArgState.classPK +ATK>��=��s�org/gradle/cli/CommandLineParser$OptionAwareParserState.classPK +A�%�̻�7��x�org/gradle/cli/CommandLineParser$OptionComparator.classPK +A�fC���8����org/gradle/cli/CommandLineParser$OptionParserState.classPK +A���E��3����org/gradle/cli/CommandLineParser$OptionString.classPK +AgAq��x=����org/gradle/cli/CommandLineParser$OptionStringComparator.classPK +A\`M~U�2��p�org/gradle/cli/CommandLineParser$ParserState.classPK +Ap�X +�k?��ıorg/gradle/cli/CommandLineParser$UnknownOptionParserState.classPK +A�=l)&����org/gradle/cli/CommandLineParser.classPK +A��>�&��X�org/gradle/cli/ParsedCommandLine.classPK +Ay�t�E,��e�org/gradle/cli/ParsedCommandLineOption.classPK +A\\\\v�B| :����org/gradle/cli/ProjectPropertiesCommandLineConverter.classPK +A +�8=|�9��]�org/gradle/cli/SystemPropertiesCommandLineConverter.classPK44J0�", + "gradle/wrapper/gradle-wrapper.properties": "distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\\\\://services.gradle.org/distributions/gradle-7.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +", + "gradlew": "#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the \\"License\\"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an \\"AS IS\\" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «\${var}», «\${var:-default}», «\${var+SET}», +# «\${var#prefix}», «\${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The \\"traditional\\" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in \\"$@\\", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=\${app_path%\\"\${app_path##*/}\\"} # leaves a trailing /; empty if no leading path + [ -h \\"$app_path\\" ] +do + ls=$( ls -ld \\"$app_path\\" ) + link=\${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd \\"\${APP_HOME:-./}\\" && pwd -P ) || exit + +APP_NAME=\\"Gradle\\" +APP_BASE_NAME=\${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 \\"-Xmx64m\\" \\"-Xms64m\\"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo \\"$*\\" +} >&2 + +die () { + echo + echo \\"$*\\" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case \\"$( uname )\\" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n \\"$JAVA_HOME\\" ] ; then + if [ -x \\"$JAVA_HOME/jre/sh/java\\" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x \\"$JAVACMD\\" ] ; then + die \\"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation.\\" + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die \\"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation.\\" +fi + +# Increase the maximum file descriptors if we can. +if ! \\"$cygwin\\" && ! \\"$darwin\\" && ! \\"$nonstop\\" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn \\"Could not query maximum file descriptor limit\\" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n \\"$MAX_FD\\" || + warn \\"Could not set maximum file descriptor limit to $MAX_FD\\" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if \\"$cygwin\\" || \\"$msys\\" ; then + APP_HOME=$( cygpath --path --mixed \\"$APP_HOME\\" ) + CLASSPATH=$( cygpath --path --mixed \\"$CLASSPATH\\" ) + + JAVACMD=$( cygpath --unix \\"$JAVACMD\\" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=\${arg#/} t=/\${t%%/*} # looks like a POSIX filepath + [ -e \\"$t\\" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed \\"$arg\\" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a \`for\` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in \`arg\`. + shift # remove old arg + set -- \\"$@\\" \\"$arg\\" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \\\\ + \\"-Dorg.gradle.appname=$APP_BASE_NAME\\" \\\\ + -classpath \\"$CLASSPATH\\" \\\\ + org.gradle.wrapper.GradleWrapperMain \\\\ + \\"$@\\" + +# Use \\"xargs\\" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<\\"$var\\" ) && +# set -- \\"\${ARGS[@]}\\" \\"$@\\" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single \\"set\\" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval \\"set -- $( + printf '%s\\\\n' \\"$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\\" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\\\\\\\&~g; ' | + tr '\\\\n' ' ' + )\\" '\\"$@\\"' + +exec \\"$JAVACMD\\" \\"$@\\" +", + "gradlew.bat": "@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the \\"License\\"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an \\"AS IS\\" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if \\"%DEBUG%\\" == \\"\\" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if \\"%OS%\\"==\\"Windows_NT\\" setlocal + +set DIRNAME=%~dp0 +if \\"%DIRNAME%\\" == \\"\\" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any \\".\\" and \\"..\\" in APP_HOME to make it shorter. +for %%i in (\\"%APP_HOME%\\") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 \\"-Xmx64m\\" \\"-Xms64m\\" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if \\"%ERRORLEVEL%\\" == \\"0\\" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:\\"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist \\"%JAVA_EXE%\\" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\\\\gradle\\\\wrapper\\\\gradle-wrapper.jar + + +@rem Execute Gradle +\\"%JAVA_EXE%\\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \\"-Dorg.gradle.appname=%APP_BASE_NAME%\\" -classpath \\"%CLASSPATH%\\" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if \\"%ERRORLEVEL%\\"==\\"0\\" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not \\"\\" == \\"%GRADLE_EXIT_CONSOLE%\\" exit 1 +exit /b 1 + +:mainEnd +if \\"%OS%\\"==\\"Windows_NT\\" endlocal + +:omega +", + "pom.xml": " + 4.0.0 + test + com.aws.pdk.test + jar + com.aws.pdk.test + 1.0.0 + https://github.com/openapitools/openapi-generator + OpenAPI Java + + scm:git:git@github.com:openapitools/openapi-generator.git + scm:git:git@github.com:openapitools/openapi-generator.git + https://github.com/openapitools/openapi-generator + + + + + Unlicense + http://unlicense.org + repo + + + + + + OpenAPI-Generator Contributors + team@openapitools.org + OpenAPITools.org + http://openapitools.org + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + true + 128m + 512m + + -Xlint:all + -J-Xss4m + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.1.0 + + + enforce-maven + + enforce + + + + + 2.2.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + 10 + + + + + org.junit.jupiter + junit-jupiter-engine + \${junit-version} + + + + + maven-dependency-plugin + 3.3.0 + + + package + + copy-dependencies + + + \${project.build.directory}/lib + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.3.0 + + + + test-jar + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.3.0 + + + add_sources + generate-sources + + add-source + + + + src/main/java + + + + + add_test_sources + generate-test-sources + + add-test-source + + + + src/test/java + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.4.1 + + + attach-javadocs + + jar + + + + + none + + + http.response.details + a + Http Response Details: + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + + com.diffplug.spotless + spotless-maven-plugin + \${spotless.version} + + + + + + + .gitignore + + + + + + true + 4 + + + + + + + + + + 1.8 + + true + + + + + + + + + + + + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.squareup.okhttp3 + okhttp + \${okhttp-version} + + + com.squareup.okhttp3 + logging-interceptor + \${okhttp-version} + + + com.google.code.gson + gson + \${gson-version} + + + io.gsonfire + gson-fire + \${gson-fire-version} + + + org.apache.commons + commons-lang3 + \${commons-lang3-version} + + + jakarta.annotation + jakarta.annotation-api + \${jakarta-annotation-version} + provided + + + org.openapitools + jackson-databind-nullable + \${jackson-databind-nullable-version} + + + + javax.ws.rs + jsr311-api + \${jsr311-api-version} + + + javax.ws.rs + javax.ws.rs-api + \${javax.ws.rs-api-version} + + + + org.junit.jupiter + junit-jupiter-engine + \${junit-version} + test + + + org.junit.platform + junit-platform-runner + \${junit-platform-runner.version} + test + + + org.mockito + mockito-core + \${mockito-core-version} + test + + + + 1.8 + \${java.version} + \${java.version} + 1.8.5 + 1.6.6 + 4.10.0 + 2.9.1 + 3.12.0 + 0.2.4 + 1.3.5 + 5.9.1 + 1.9.1 + 3.12.4 + 2.1.1 + 1.1.1 + UTF-8 + 2.27.2 + + +", + "settings.gradle": "rootProject.name = \\"com.aws.pdk.test\\"", + "src/main/AndroidManifest.xml": " + + +", + "src/main/java/org/acme/Main.java": "package org.acme; + +public class Main { + public static void main(final String[] args) { + System.out.println(\\"Hello, world!\\"); + } +}", + "src/main/java/test/test/client/ApiCallback.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +import java.io.IOException; + +import java.util.Map; +import java.util.List; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} +", + "src/main/java/test/test/client/ApiClient.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; + +import javax.net.ssl.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URI; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.text.DateFormat; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import test.test.client.auth.Authentication; +import test.test.client.auth.HttpBasicAuth; +import test.test.client.auth.HttpBearerAuth; +import test.test.client.auth.ApiKeyAuth; + +/** + *

ApiClient class.

+ */ +public class ApiClient { + + private String basePath = \\"http://localhost\\"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + \\"\\", + \\"No description provided\\", + new HashMap() + ) + )); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + private boolean debugging = false; + private Map defaultHeaderMap = new HashMap(); + private Map defaultCookieMap = new HashMap(); + private String tempFolderPath = null; + + private Map authentications; + + private DateFormat dateFormat; + private DateFormat datetimeFormat; + private boolean lenientDatetimeFormat; + private int dateLength; + + private InputStream sslCaCert; + private boolean verifyingSsl; + private KeyManager[] keyManagers; + + private OkHttpClient httpClient; + private JSON json; + + private HttpLoggingInterceptor loggingInterceptor; + + /** + * Basic constructor for ApiClient + */ + public ApiClient() { + init(); + initHttpClient(); + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * Basic constructor with custom OkHttpClient + * + * @param client a {@link okhttp3.OkHttpClient} object + */ + public ApiClient(OkHttpClient client) { + init(); + + httpClient = client; + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + private void initHttpClient() { + initHttpClient(Collections.emptyList()); + } + + private void initHttpClient(List interceptors) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + for (Interceptor interceptor: interceptors) { + builder.addInterceptor(interceptor); + } + + httpClient = builder.build(); + } + + private void init() { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent(\\"OpenAPI-Generator/1.0.0/java\\"); + + authentications = new HashMap(); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g http://localhost + * @return An instance of OkHttpClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client, which must never be null. + * + * @param newHttpClient An instance of OkHttpClient + * @return Api Client + * @throws java.lang.NullPointerException when newHttpClient is null + */ + public ApiClient setHttpClient(OkHttpClient newHttpClient) { + this.httpClient = Objects.requireNonNull(newHttpClient, \\"HttpClient must not be null!\\"); + return this; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. + * Default to true. + * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. + * Use null to reset to default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + *

Getter for the field keyManagers.

+ * + * @return an array of {@link javax.net.ssl.KeyManager} objects + */ + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. + * Use null to reset to default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + /** + *

Getter for the field dateFormat.

+ * + * @return a {@link java.text.DateFormat} object + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + *

Setter for the field dateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link test.test.client.ApiClient} object + */ + public ApiClient setDateFormat(DateFormat dateFormat) { + JSON.setDateFormat(dateFormat); + return this; + } + + /** + *

Set SqlDateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link test.test.client.ApiClient} object + */ + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + JSON.setSqlDateFormat(dateFormat); + return this; + } + + /** + *

Set OffsetDateTimeFormat.

+ * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link test.test.client.ApiClient} object + */ + public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + JSON.setOffsetDateTimeFormat(dateFormat); + return this; + } + + /** + *

Set LocalDateFormat.

+ * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link test.test.client.ApiClient} object + */ + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateFormat(dateFormat); + return this; + } + + /** + *

Set LenientOnJson.

+ * + * @param lenientOnJson a boolean + * @return a {@link test.test.client.ApiClient} object + */ + public ApiClient setLenientOnJson(boolean lenientOnJson) { + JSON.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + + /** + * Helper method to set username for the first HTTP basic authentication. + * + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException(\\"No HTTP basic authentication configured!\\"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException(\\"No HTTP basic authentication configured!\\"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException(\\"No API key authentication configured!\\"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException(\\"No API key authentication configured!\\"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + throw new RuntimeException(\\"No OAuth2 authentication configured!\\"); + } + + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException(\\"No AWS4 authentication configured!\\"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader(\\"User-Agent\\", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default temporary folder. + * + * @see createTempFile + * @return Temporary folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.connectTimeoutMillis(); + } + + /** + * Sets the connect timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get read timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.readTimeoutMillis(); + } + + /** + * Sets the read timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get write timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.writeTimeoutMillis(); + } + + /** + * Sets the write timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return \\"\\"; + } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { + //Serialize to json string and remove the \\" enclosing characters + String jsonStr = JSON.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(\\",\\"); + } + b.append(o); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + * Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if (\\"multi\\".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be \\"csv\\" by default + String delimiter = \\",\\"; + + // escape all delimiters except commas, which are URI reserved + // characters + if (\\"ssv\\".equals(collectionFormat)) { + delimiter = escapeString(\\" \\"); + } else if (\\"tsv\\".equals(collectionFormat)) { + delimiter = escapeString(\\"\\\\t\\"); + } else if (\\"pipes\\".equals(collectionFormat)) { + delimiter = escapeString(\\"|\\"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if (\\"multi\\".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be \\"csv\\" by default + String delimiter = \\",\\"; + + if (\\"ssv\\".equals(collectionFormat)) { + delimiter = \\" \\"; + } else if (\\"tsv\\".equals(collectionFormat)) { + delimiter = \\"\\\\t\\"; + } else if (\\"pipes\\".equals(collectionFormat)) { + delimiter = \\"|\\"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceAll(\\".*[/\\\\\\\\\\\\\\\\]\\", \\"\\"); + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * \\"* / *\\" is also default to JSON + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = \\"(?i)^(application/json|[^;/ \\\\t]+/[^;/ \\\\t]+[+]json)[ \\\\t]*(;.*)?$\\"; + return mime != null && (mime.matches(jsonMime) || mime.equals(\\"*/*\\")); + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, \\",\\"); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * returns null. If it matches \\"any\\", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals(\\"*/*\\")) { + return \\"application/json\\"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, \\"utf8\\").replaceAll(\\"\\\\\\\\+\\", \\"%20\\"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and + * the Content-Type response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws test.test.client.ApiException If fail to deserialize response body, i.e. cannot read response body + * or the Content-Type of the response is not supported. + */ + @SuppressWarnings(\\"unchecked\\") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if (\\"byte[]\\".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + String respBody; + try { + if (response.body() != null) + respBody = response.body().string(); + else + respBody = null; + } catch (IOException e) { + throw new ApiException(e); + } + + if (respBody == null || \\"\\".equals(respBody)) { + return null; + } + + String contentType = response.headers().get(\\"Content-Type\\"); + if (contentType == null) { + // ensuring a default content type + contentType = \\"application/json\\"; + } + if (isJsonMime(contentType)) { + return JSON.deserialize(respBody, returnType); + } else if (returnType.equals(String.class)) { + // Expecting string, return the raw response body. + return (T) respBody; + } else { + throw new ApiException( + \\"Content type \\\\\\"\\" + contentType + \\"\\\\\\" is not supported for type: \\" + returnType, + response.code(), + response.headers().toMultimap(), + respBody); + } + } + + /** + * Serialize the given Java object into request body according to the object's + * class and the request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws test.test.client.ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create((File) obj, MediaType.parse(contentType)); + } else if (\\"text/plain\\".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else { + throw new ApiException(\\"Content type \\\\\\"\\" + contentType + \\"\\\\\\" is not supported\\"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @throws test.test.client.ApiException If fail to read file content from response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws java.io.IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header(\\"Content-Disposition\\"); + if (contentDisposition != null && !\\"\\".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile(\\"filename=['\\\\\\"]?([^'\\\\\\"\\\\\\\\s]+)['\\\\\\"]?\\"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = \\"download-\\"; + suffix = \\"\\"; + } else { + int pos = filename.lastIndexOf(\\".\\"); + if (pos == -1) { + prefix = filename + \\"-\\"; + } else { + prefix = filename.substring(0, pos) + \\"-\\"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) + prefix = \\"download-\\"; + } + + if (tempFolderPath == null) + return Files.createTempFile(prefix, suffix).toFile(); + else + return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws test.test.client.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and + * data, which is a Java object deserialized from response body and would be null + * when returnType is null. + * @throws test.test.client.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings(\\"unchecked\\") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } catch (Exception e) { + callback.onFailure(new ApiException(e), response.code(), response.headers().toMultimap()); + return; + } + callback.onSuccess(result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws test.test.client.ApiException If the response has an unsuccessful status code or + * fail to deserialize the response body + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (Exception e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of \\"GET\\", \\"HEAD\\", \\"OPTIONS\\", \\"POST\\", \\"PUT\\", \\"PATCH\\" and \\"DELETE\\" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws test.test.client.ApiException If fail to serialize the request body object + */ + public Call buildCall(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + Request request = buildRequest(baseUrl, path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of \\"GET\\", \\"HEAD\\", \\"OPTIONS\\", \\"POST\\", \\"PUT\\", \\"PATCH\\" and \\"DELETE\\" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws test.test.client.ApiException If fail to serialize the request body object + */ + public Request buildRequest(String baseUrl, String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams + List allQueryParams = new ArrayList(queryParams); + allQueryParams.addAll(collectionQueryParams); + + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get(\\"Content-Type\\"); + + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if (\\"application/x-www-form-urlencoded\\".equals(contentType)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if (\\"multipart/form-data\\".equals(contentType)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if (\\"DELETE\\".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = RequestBody.create(\\"\\", contentType == null ? null : MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + // update parameters with authentication settings + updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + \\"Invalid index %d when selecting the host settings. Must be less than %d\\", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in \`path\`, e.g. \\"/posts?draft=1\\" + String prefix = path.contains(\\"?\\") ? \\"&\\" : \\"?\\"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append(\\"&\\"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append(\\"=\\").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains(\\"?\\") ? \\"&\\" : \\"?\\"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append(\\"&\\"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append(\\"=\\").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader(\\"Cookie\\", String.format(\\"%s=%s\\", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader(\\"Cookie\\", String.format(\\"%s=%s\\", param.getKey(), param.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws test.test.client.ApiException If fails to update the parameters + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException(\\"Authentication undefined: \\" + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, + * which could contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item: list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to \\"application/octet-stream\\"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return \\"application/octet-stream\\"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = Headers.of(\\"Content-Disposition\\", \\"form-data; name=\\\\\\"\\" + key + \\"\\\\\\"; filename=\\\\\\"\\" + file.getName() + \\"\\\\\\"\\"); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse(\\"text/plain\\")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse(\\"application/json\\")); + } + + Headers partHeaders = Headers.of(\\"Content-Disposition\\", \\"form-data; name=\\\\\\"\\" + key + \\"\\\\\\"\\"); + mpBuilder.addPart(partHeaders, requestBody); + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for + * async requests. + */ + private Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of + * verifyingSsl and sslCaCert. + */ + private void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = new TrustManager[]{ + new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[]{}; + } + } + }; + hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance(\\"X.509\\"); + Collection certificates = certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException(\\"expected non-empty set of trusted certificates\\"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = \\"ca\\" + (index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + + SSLContext sslContext = SSLContext.getInstance(\\"TLS\\"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = httpClient.newBuilder() + .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws test.test.client.ApiException If fail to serialize the request body object into a string + */ + private String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return \\"\\"; + } +} +", + "src/main/java/test/test/client/ApiException.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +import java.util.Map; +import java.util.List; + +import javax.ws.rs.core.GenericType; + +/** + *

ApiException class.

+ */ +@SuppressWarnings(\\"serial\\") +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public class ApiException extends Exception { + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + /** + *

Constructor for ApiException.

+ */ + public ApiException() {} + + /** + *

Constructor for ApiException.

+ * + * @param throwable a {@link java.lang.Throwable} object + */ + public ApiException(Throwable throwable) { + super(throwable); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + */ + public ApiException(String message) { + super(message); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, Map> responseHeaders, String responseBody) { + this(\\"Response Code: \\" + code + \\" Response Body: \\" + responseBody, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message a {@link java.lang.String} object + */ + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message the error message + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } + + /** + * Get the exception message including HTTP response data. + * + * @return The exception message + */ + public String getMessage() { + return String.format(\\"Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s\\", + super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); + } +} +", + "src/main/java/test/test/client/ApiResponse.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + */ +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + *

Constructor for ApiResponse.

+ * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + /** + *

Get the status code.

+ * + * @return the status code + */ + public int getStatusCode() { + return statusCode; + } + + /** + *

Get the headers.

+ * + * @return a {@link java.util.Map} of headers + */ + public Map> getHeaders() { + return headers; + } + + /** + *

Get the data.

+ * + * @return the data + */ + public T getData() { + return data; + } +} +", + "src/main/java/test/test/client/Configuration.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public class Configuration { + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} +", + "src/main/java/test/test/client/GzipRequestInterceptor.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +import java.io.IOException; + +/** + * Encodes request bodies using gzip. + * + * Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header(\\"Content-Encoding\\") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder() + .header(\\"Content-Encoding\\", \\"gzip\\") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} +", + "src/main/java/test/test/client/JSON.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; + +import okio.ByteString; + +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.HashMap; + +/* + * A JSON utility class + * + * NOTE: in the future, this class may be converted to static, which may break + * backward-compatibility + */ +public class JSON { + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + @SuppressWarnings(\\"unchecked\\") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + ; + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException(\\"missing discriminator field: <\\" + discriminatorField + \\">\\"); + } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified discriminator value. + * + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); + if (null == clazz) { + throw new IllegalArgumentException(\\"cannot determine model class of name: <\\" + discriminatorValue + \\">\\"); + } + return clazz; + } + + { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gson = gsonBuilder.create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public static Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + */ + public static void setGson(Gson gson) { + JSON.gson = gson; + } + + public static void setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public static String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings(\\"unchecked\\") + public static T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } + } + } + + /** + * Gson TypeAdapter for Byte Array type + */ + public static class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith(\\"+0000\\")) { + date = date.substring(0, date.length()-5) + \\"Z\\"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public static class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } + + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } + + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple \\"yyyy-MM-dd\\" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() {} + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() {} + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } + + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} +", + "src/main/java/test/test/client/Pair.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public class Pair { + private String name = \\"\\"; + private String value = \\"\\"; + + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + return true; + } +} +", + "src/main/java/test/test/client/ProgressRequestBody.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +import okhttp3.MediaType; +import okhttp3.RequestBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} +", + "src/main/java/test/test/client/ProgressResponseBody.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +import okhttp3.MediaType; +import okhttp3.ResponseBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} +", + "src/main/java/test/test/client/ServerConfiguration.java": "package test.test.client; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for substitution in the server's URL template. + */ + public ServerConfiguration(String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable: this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException(\\"The variable \\" + name + \\" in the server URL has invalid value \\" + value + \\".\\"); + } + } + url = url.replace(\\"{\\" + name + \\"}\\", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} +", + "src/main/java/test/test/client/ServerVariable.java": "package test.test.client; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} +", + "src/main/java/test/test/client/StringUtil.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + *

+ * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + *

+ * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return \\"\\"; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} +", + "src/main/java/test/test/client/api/DefaultApi.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client.api; + +import test.test.client.ApiCallback; +import test.test.client.ApiClient; +import test.test.client.ApiException; +import test.test.client.ApiResponse; +import test.test.client.Configuration; +import test.test.client.Pair; +import test.test.client.ProgressRequestBody; +import test.test.client.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.ws.rs.core.GenericType; + +public class DefaultApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public DefaultApi() { + this(Configuration.getDefaultApiClient()); + } + + public DefaultApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + private okhttp3.Call neitherCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = \\"/neither\\"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put(\\"Accept\\", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put(\\"Content-Type\\", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, \\"GET\\", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings(\\"rawtypes\\") + private okhttp3.Call neitherValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return neitherCall(_callback); + + } + + + private ApiResponse neitherWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = neitherValidateBeforeCall(null); + return localVarApiClient.execute(localVarCall); + } + + private okhttp3.Call neitherAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = neitherValidateBeforeCall(_callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + public class APIneitherRequest { + + private APIneitherRequest() { + } + + /** + * Build call for neither + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return neitherCall(_callback); + } + + /** + * Execute neither request + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public void execute() throws ApiException { + neitherWithHttpInfo(); + } + + /** + * Execute neither request with HTTP info returned + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return neitherWithHttpInfo(); + } + + /** + * Execute neither request (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return neitherAsync(_callback); + } + } + + /** + * + * + * @return APIneitherRequest + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public APIneitherRequest neither() { + return new APIneitherRequest(); + } +} +", + "src/main/java/test/test/client/api/DefaultApi/Handlers.java": "package test.test.client.api; + +import test.test.client.model.*; + +import java.util.Arrays; +import java.util.Optional; +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import java.util.Collections; +import java.util.stream.Collectors; +import java.io.UnsupportedEncodingException; +import java.io.IOException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.amazonaws.services.lambda.runtime.Context; +import com.amazonaws.services.lambda.runtime.RequestHandler; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent; +import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent; + + +import test.test.client.JSON; + +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public class Handlers { + + static { + // JSON has a static instance of Gson which is instantiated lazily the first time it is initialised. + // Create an instance here to ensure that the static Gson instance is always available. + new JSON(); + } + + private static String decodeParameter(final String parameter) { + try { + return URLDecoder.decode(parameter, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + + private static Map decodeRequestParameters(Map parameters) { + Map decodedParameters = new HashMap<>(); + for(Map.Entry parameter : parameters.entrySet()) { + decodedParameters.put(parameter.getKey(), decodeParameter(parameter.getValue())); + } + return decodedParameters; + } + + private static Map> decodeRequestArrayParameters(Map> parameters) { + Map> decodedParameters = new HashMap<>(); + for(Map.Entry> parameter : parameters.entrySet()) { + decodedParameters.put(parameter.getKey(), parameter.getValue().stream().map(Handlers::decodeParameter).collect(Collectors.toList())); + } + return decodedParameters; + } + + private static void putAllFromNullableMap(Map source, Map destination) { + if (source != null) { + destination.putAll(source); + } + } + + private static String concatMethodAndPath(final String method, final String path) { + return String.format(\\"%s||%s\\", method.toLowerCase(), path); + } + + private static List> getAnnotationInterceptors(Class clazz) { + // Support specifying simple interceptors via the @Interceptors({ MyInterceptor.class, MyOtherInterceptor.class }) format + return clazz.isAnnotationPresent(Interceptors.class) + ? Arrays.stream(clazz.getAnnotation(Interceptors.class).value()).map(c -> { + try { + return (Interceptor) c.getDeclaredConstructor().newInstance(); + } catch (Exception e) { + throw new RuntimeException(String.format( + \\"Cannot create instance of interceptor %s. Please ensure it has a public constructor \\" + + \\"with no arguments, or override the getInterceptors method instead of using the annotation\\", c.getSimpleName()), e); + } + }).collect(Collectors.toList()) + : new ArrayList<>(); + } + + /** + * Represents an HTTP response from an api operation + */ + public static interface Response { + /** + * Returns the response body + */ + String getBody(); + /** + * Returns the response status code + */ + int getStatusCode(); + /** + * Returns the response headers + */ + Map getHeaders(); + } + + @lombok.experimental.SuperBuilder + @lombok.AllArgsConstructor + @lombok.Getter + public static class ApiResponse implements Response { + private String body; + private int statusCode; + private Map headers; + } + + /** + * Interceptors can perform generic operations on requests and/or responses, optionally delegating to the remainder + * of the request chain. + */ + public static interface Interceptor { + /** + * Handle a request. Usually the response from \`input.getChain().next(input)\` is returned to delegate to the + * remainder of the chain, however you may wish to return an alternative Response. + */ + Response handle(ChainedRequestInput input); + } + + /** + * Use this annotation to add interceptors to the request handler. Interceptors used in the annotation must have a + * constructor with no arguments. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public static @interface Interceptors { + public Class[] value() default {}; + } + + /** + * A handler chain represents a series of interceptors, which may or may not delegate to following interceptors. + * The lambda handler is always the last method in the chain. + */ + public static interface HandlerChain { + /** + * Delegate to the remainder of the handler chain + */ + Response next(ChainedRequestInput input); + } + + /** + * Defines the input for a request. + */ + public static interface RequestInput { + /** + * The raw event from API Gateway + */ + APIGatewayProxyRequestEvent getEvent(); + /** + * Lambda execution context + */ + Context getContext(); + /** + * Demarshalled request input + */ + TInput getInput(); + /** + * Storage for arbitrary interceptor context for the lifetime of the request. Set and get values to pass state + * between interceptors or to the final handler. + */ + Map getInterceptorContext(); + } + + /** + * Reqeust input with a handler chain + */ + public static interface ChainedRequestInput extends RequestInput { + /** + * The chain for handling requests + */ + HandlerChain getChain(); + } + + private static HandlerChain buildHandlerChain(final List> interceptors, final HandlerChain baseChain) { + if (interceptors.isEmpty()) { + return baseChain; + } else { + Interceptor interceptor = interceptors.get(0); + HandlerChain remainingChain = buildHandlerChain(interceptors.subList(1, interceptors.size()), baseChain); + return new HandlerChain() { + @Override + public Response next(ChainedRequestInput input) { + return interceptor.handle(new ChainedRequestInput() { + @Override + public APIGatewayProxyRequestEvent getEvent() { + return input.getEvent(); + } + + @Override + public Context getContext() { + return input.getContext(); + } + + @Override + public TInput getInput() { + return input.getInput(); + } + + @Override + public HandlerChain getChain() { + return remainingChain; + } + + @Override + public Map getInterceptorContext() { + return input.getInterceptorContext(); + } + }); + } + }; + } + } + + /** + * Response for the neither operation + */ + public static interface NeitherResponse extends Response {} + + /** + * Response with status code 200 for the neither operation + */ + public static class Neither200Response implements NeitherResponse { + private String body; + private Map headers; + + private Neither200Response(final Map headers) { + this.body = \\"\\"; + this.headers = headers; + } + + @Override + public int getStatusCode() { + return 200; + } + + @Override + public String getBody() { + return this.body; + } + + @Override + public Map getHeaders() { + return this.headers; + } + + /** + * Create a Neither200Response without a body + */ + public static Neither200Response of() { + return new Neither200Response(new HashMap<>()); + } + + /** + * Create a Neither200Response without a body and headers + */ + public static Neither200Response of(final Map headers) { + return new Neither200Response(headers); + } + } + + /** + * Single-value query and path parameters for the neither operation + */ + public static class NeitherRequestParameters { + + public NeitherRequestParameters(final APIGatewayProxyRequestEvent event) { + Map parameters = new HashMap<>(); + putAllFromNullableMap(event.getPathParameters(), parameters); + putAllFromNullableMap(event.getQueryStringParameters(), parameters); + Map decodedParameters = decodeRequestParameters(parameters); + + } + + } + + /** + * Multi-value query parameters for the neither operation + */ + public static class NeitherRequestArrayParameters { + + public NeitherRequestArrayParameters(final APIGatewayProxyRequestEvent event) { + Map> parameters = new HashMap<>(); + putAllFromNullableMap(event.getMultiValueQueryStringParameters(), parameters); + Map> decodedParameters = decodeRequestArrayParameters(parameters); + + } + + } + + /** + * Input for the neither operation + */ + public static class NeitherInput { + private NeitherRequestParameters requestParameters; + private NeitherRequestArrayParameters requestArrayParameters; + + public NeitherInput(final APIGatewayProxyRequestEvent event) { + this.requestParameters = new NeitherRequestParameters(event); + this.requestArrayParameters = new NeitherRequestArrayParameters(event); + } + + public NeitherRequestParameters getRequestParameters() { + return this.requestParameters; + } + + public NeitherRequestArrayParameters getRequestArrayParameters() { + return this.requestArrayParameters; + } + + } + + /** + * Full request input for the neither operation, including the raw API Gateway event + */ + public static class NeitherRequestInput implements RequestInput { + private APIGatewayProxyRequestEvent event; + private Context context; + private Map interceptorContext; + private NeitherInput input; + + public NeitherRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final Map interceptorContext, final NeitherInput input) { + this.event = event; + this.context = context; + this.interceptorContext = interceptorContext; + this.input = input; + } + + /** + * Returns the typed request input, with path, query and body parameters + */ + public NeitherInput getInput() { + return this.input; + } + + /** + * Returns the raw API Gateway event + */ + public APIGatewayProxyRequestEvent getEvent() { + return this.event; + } + + /** + * Returns the lambda context + */ + public Context getContext() { + return this.context; + } + + /** + * Returns the interceptor context, which may contain values set by request interceptors + */ + public Map getInterceptorContext() { + return this.interceptorContext; + } + } + + /** + * Lambda handler wrapper for the neither operation + */ + public static abstract class Neither implements RequestHandler { + /** + * Handle the request for the neither operation + */ + public abstract NeitherResponse handle(final NeitherRequestInput request); + + /** + * For more complex interceptors that require instantiation with parameters, you may override this method to + * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, + * prefer the @Interceptors annotation. + */ + public List> getInterceptors() { + return Collections.emptyList(); + } + + @Override + public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent event, final Context context) { + return this.handleRequestWithAdditionalInterceptors(event, context, new ArrayList<>()); + } + + public APIGatewayProxyResponseEvent handleRequestWithAdditionalInterceptors(final APIGatewayProxyRequestEvent event, final Context context, final List> additionalInterceptors) { + final Map interceptorContext = new HashMap<>(); + + List> interceptors = new ArrayList<>(); + interceptors.addAll(additionalInterceptors); + + List> annotationInterceptors = getAnnotationInterceptors(this.getClass()); + + interceptors.addAll(annotationInterceptors); + interceptors.addAll(this.getInterceptors()); + + final HandlerChain chain = buildHandlerChain(interceptors, new HandlerChain() { + @Override + public Response next(ChainedRequestInput input) { + return handle(new NeitherRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); + } + }); + + final Response response = chain.next(new ChainedRequestInput() { + @Override + public HandlerChain getChain() { + // The chain's next method ignores the chain given as input, and is pre-built to follow the remaining + // chain. + return null; + } + + @Override + public APIGatewayProxyRequestEvent getEvent() { + return event; + } + + @Override + public Context getContext() { + return context; + } + + @Override + public NeitherInput getInput() { + return new NeitherInput(event); + } + + @Override + public Map getInterceptorContext() { + return interceptorContext; + } + }); + + return new APIGatewayProxyResponseEvent() + .withStatusCode(response.getStatusCode()) + .withHeaders(response.getHeaders()) + .withBody(response.getBody()); + } + } + + /** + * Response for the both operation + */ + public static interface BothResponse extends Response {} + + /** + * Response with status code 200 for the both operation + */ + public static class Both200Response implements BothResponse { + private String body; + private Map headers; + + private Both200Response(final Map headers) { + this.body = \\"\\"; + this.headers = headers; + } + + @Override + public int getStatusCode() { + return 200; + } + + @Override + public String getBody() { + return this.body; + } + + @Override + public Map getHeaders() { + return this.headers; + } + + /** + * Create a Both200Response without a body + */ + public static Both200Response of() { + return new Both200Response(new HashMap<>()); + } + + /** + * Create a Both200Response without a body and headers + */ + public static Both200Response of(final Map headers) { + return new Both200Response(headers); + } + } + + /** + * Single-value query and path parameters for the both operation + */ + public static class BothRequestParameters { + + public BothRequestParameters(final APIGatewayProxyRequestEvent event) { + Map parameters = new HashMap<>(); + putAllFromNullableMap(event.getPathParameters(), parameters); + putAllFromNullableMap(event.getQueryStringParameters(), parameters); + Map decodedParameters = decodeRequestParameters(parameters); + + } + + } + + /** + * Multi-value query parameters for the both operation + */ + public static class BothRequestArrayParameters { + + public BothRequestArrayParameters(final APIGatewayProxyRequestEvent event) { + Map> parameters = new HashMap<>(); + putAllFromNullableMap(event.getMultiValueQueryStringParameters(), parameters); + Map> decodedParameters = decodeRequestArrayParameters(parameters); + + } + + } + + /** + * Input for the both operation + */ + public static class BothInput { + private BothRequestParameters requestParameters; + private BothRequestArrayParameters requestArrayParameters; + + public BothInput(final APIGatewayProxyRequestEvent event) { + this.requestParameters = new BothRequestParameters(event); + this.requestArrayParameters = new BothRequestArrayParameters(event); + } + + public BothRequestParameters getRequestParameters() { + return this.requestParameters; + } + + public BothRequestArrayParameters getRequestArrayParameters() { + return this.requestArrayParameters; + } + + } + + /** + * Full request input for the both operation, including the raw API Gateway event + */ + public static class BothRequestInput implements RequestInput { + private APIGatewayProxyRequestEvent event; + private Context context; + private Map interceptorContext; + private BothInput input; + + public BothRequestInput(final APIGatewayProxyRequestEvent event, final Context context, final Map interceptorContext, final BothInput input) { + this.event = event; + this.context = context; + this.interceptorContext = interceptorContext; + this.input = input; + } + + /** + * Returns the typed request input, with path, query and body parameters + */ + public BothInput getInput() { + return this.input; + } + + /** + * Returns the raw API Gateway event + */ + public APIGatewayProxyRequestEvent getEvent() { + return this.event; + } + + /** + * Returns the lambda context + */ + public Context getContext() { + return this.context; + } + + /** + * Returns the interceptor context, which may contain values set by request interceptors + */ + public Map getInterceptorContext() { + return this.interceptorContext; + } + } + + /** + * Lambda handler wrapper for the both operation + */ + public static abstract class Both implements RequestHandler { + /** + * Handle the request for the both operation + */ + public abstract BothResponse handle(final BothRequestInput request); + + /** + * For more complex interceptors that require instantiation with parameters, you may override this method to + * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, + * prefer the @Interceptors annotation. + */ + public List> getInterceptors() { + return Collections.emptyList(); + } + + @Override + public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent event, final Context context) { + return this.handleRequestWithAdditionalInterceptors(event, context, new ArrayList<>()); + } + + public APIGatewayProxyResponseEvent handleRequestWithAdditionalInterceptors(final APIGatewayProxyRequestEvent event, final Context context, final List> additionalInterceptors) { + final Map interceptorContext = new HashMap<>(); + + List> interceptors = new ArrayList<>(); + interceptors.addAll(additionalInterceptors); + + List> annotationInterceptors = getAnnotationInterceptors(this.getClass()); + + interceptors.addAll(annotationInterceptors); + interceptors.addAll(this.getInterceptors()); + + final HandlerChain chain = buildHandlerChain(interceptors, new HandlerChain() { + @Override + public Response next(ChainedRequestInput input) { + return handle(new BothRequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); + } + }); + + final Response response = chain.next(new ChainedRequestInput() { + @Override + public HandlerChain getChain() { + // The chain's next method ignores the chain given as input, and is pre-built to follow the remaining + // chain. + return null; + } + + @Override + public APIGatewayProxyRequestEvent getEvent() { + return event; + } + + @Override + public Context getContext() { + return context; + } + + @Override + public BothInput getInput() { + return new BothInput(event); + } + + @Override + public Map getInterceptorContext() { + return interceptorContext; + } + }); + + return new APIGatewayProxyResponseEvent() + .withStatusCode(response.getStatusCode()) + .withHeaders(response.getHeaders()) + .withBody(response.getBody()); + } + } + + /** + * Response for the tag1 operation + */ + public static interface Tag1Response extends Response {} + + /** + * Response with status code 200 for the tag1 operation + */ + public static class Tag1200Response implements Tag1Response { + private String body; + private Map headers; + + private Tag1200Response(final Map headers) { + this.body = \\"\\"; + this.headers = headers; + } + + @Override + public int getStatusCode() { + return 200; + } + + @Override + public String getBody() { + return this.body; + } + + @Override + public Map getHeaders() { + return this.headers; + } + + /** + * Create a Tag1200Response without a body + */ + public static Tag1200Response of() { + return new Tag1200Response(new HashMap<>()); + } + + /** + * Create a Tag1200Response without a body and headers + */ + public static Tag1200Response of(final Map headers) { + return new Tag1200Response(headers); + } + } + + /** + * Single-value query and path parameters for the tag1 operation + */ + public static class Tag1RequestParameters { + + public Tag1RequestParameters(final APIGatewayProxyRequestEvent event) { + Map parameters = new HashMap<>(); + putAllFromNullableMap(event.getPathParameters(), parameters); + putAllFromNullableMap(event.getQueryStringParameters(), parameters); + Map decodedParameters = decodeRequestParameters(parameters); + + } + + } + + /** + * Multi-value query parameters for the tag1 operation + */ + public static class Tag1RequestArrayParameters { + + public Tag1RequestArrayParameters(final APIGatewayProxyRequestEvent event) { + Map> parameters = new HashMap<>(); + putAllFromNullableMap(event.getMultiValueQueryStringParameters(), parameters); + Map> decodedParameters = decodeRequestArrayParameters(parameters); + + } + + } + + /** + * Input for the tag1 operation + */ + public static class Tag1Input { + private Tag1RequestParameters requestParameters; + private Tag1RequestArrayParameters requestArrayParameters; + + public Tag1Input(final APIGatewayProxyRequestEvent event) { + this.requestParameters = new Tag1RequestParameters(event); + this.requestArrayParameters = new Tag1RequestArrayParameters(event); + } + + public Tag1RequestParameters getRequestParameters() { + return this.requestParameters; + } + + public Tag1RequestArrayParameters getRequestArrayParameters() { + return this.requestArrayParameters; + } + + } + + /** + * Full request input for the tag1 operation, including the raw API Gateway event + */ + public static class Tag1RequestInput implements RequestInput { + private APIGatewayProxyRequestEvent event; + private Context context; + private Map interceptorContext; + private Tag1Input input; + + public Tag1RequestInput(final APIGatewayProxyRequestEvent event, final Context context, final Map interceptorContext, final Tag1Input input) { + this.event = event; + this.context = context; + this.interceptorContext = interceptorContext; + this.input = input; + } + + /** + * Returns the typed request input, with path, query and body parameters + */ + public Tag1Input getInput() { + return this.input; + } + + /** + * Returns the raw API Gateway event + */ + public APIGatewayProxyRequestEvent getEvent() { + return this.event; + } + + /** + * Returns the lambda context + */ + public Context getContext() { + return this.context; + } + + /** + * Returns the interceptor context, which may contain values set by request interceptors + */ + public Map getInterceptorContext() { + return this.interceptorContext; + } + } + + /** + * Lambda handler wrapper for the tag1 operation + */ + public static abstract class Tag1 implements RequestHandler { + /** + * Handle the request for the tag1 operation + */ + public abstract Tag1Response handle(final Tag1RequestInput request); + + /** + * For more complex interceptors that require instantiation with parameters, you may override this method to + * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, + * prefer the @Interceptors annotation. + */ + public List> getInterceptors() { + return Collections.emptyList(); + } + + @Override + public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent event, final Context context) { + return this.handleRequestWithAdditionalInterceptors(event, context, new ArrayList<>()); + } + + public APIGatewayProxyResponseEvent handleRequestWithAdditionalInterceptors(final APIGatewayProxyRequestEvent event, final Context context, final List> additionalInterceptors) { + final Map interceptorContext = new HashMap<>(); + + List> interceptors = new ArrayList<>(); + interceptors.addAll(additionalInterceptors); + + List> annotationInterceptors = getAnnotationInterceptors(this.getClass()); + + interceptors.addAll(annotationInterceptors); + interceptors.addAll(this.getInterceptors()); + + final HandlerChain chain = buildHandlerChain(interceptors, new HandlerChain() { + @Override + public Response next(ChainedRequestInput input) { + return handle(new Tag1RequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); + } + }); + + final Response response = chain.next(new ChainedRequestInput() { + @Override + public HandlerChain getChain() { + // The chain's next method ignores the chain given as input, and is pre-built to follow the remaining + // chain. + return null; + } + + @Override + public APIGatewayProxyRequestEvent getEvent() { + return event; + } + + @Override + public Context getContext() { + return context; + } + + @Override + public Tag1Input getInput() { + return new Tag1Input(event); + } + + @Override + public Map getInterceptorContext() { + return interceptorContext; + } + }); + + return new APIGatewayProxyResponseEvent() + .withStatusCode(response.getStatusCode()) + .withHeaders(response.getHeaders()) + .withBody(response.getBody()); + } + } + + /** + * Response for the tag2 operation + */ + public static interface Tag2Response extends Response {} + + /** + * Response with status code 200 for the tag2 operation + */ + public static class Tag2200Response implements Tag2Response { + private String body; + private Map headers; + + private Tag2200Response(final Map headers) { + this.body = \\"\\"; + this.headers = headers; + } + + @Override + public int getStatusCode() { + return 200; + } + + @Override + public String getBody() { + return this.body; + } + + @Override + public Map getHeaders() { + return this.headers; + } + + /** + * Create a Tag2200Response without a body + */ + public static Tag2200Response of() { + return new Tag2200Response(new HashMap<>()); + } + + /** + * Create a Tag2200Response without a body and headers + */ + public static Tag2200Response of(final Map headers) { + return new Tag2200Response(headers); + } + } + + /** + * Single-value query and path parameters for the tag2 operation + */ + public static class Tag2RequestParameters { + + public Tag2RequestParameters(final APIGatewayProxyRequestEvent event) { + Map parameters = new HashMap<>(); + putAllFromNullableMap(event.getPathParameters(), parameters); + putAllFromNullableMap(event.getQueryStringParameters(), parameters); + Map decodedParameters = decodeRequestParameters(parameters); + + } + + } + + /** + * Multi-value query parameters for the tag2 operation + */ + public static class Tag2RequestArrayParameters { + + public Tag2RequestArrayParameters(final APIGatewayProxyRequestEvent event) { + Map> parameters = new HashMap<>(); + putAllFromNullableMap(event.getMultiValueQueryStringParameters(), parameters); + Map> decodedParameters = decodeRequestArrayParameters(parameters); + + } + + } + + /** + * Input for the tag2 operation + */ + public static class Tag2Input { + private Tag2RequestParameters requestParameters; + private Tag2RequestArrayParameters requestArrayParameters; + + public Tag2Input(final APIGatewayProxyRequestEvent event) { + this.requestParameters = new Tag2RequestParameters(event); + this.requestArrayParameters = new Tag2RequestArrayParameters(event); + } + + public Tag2RequestParameters getRequestParameters() { + return this.requestParameters; + } + + public Tag2RequestArrayParameters getRequestArrayParameters() { + return this.requestArrayParameters; + } + + } + + /** + * Full request input for the tag2 operation, including the raw API Gateway event + */ + public static class Tag2RequestInput implements RequestInput { + private APIGatewayProxyRequestEvent event; + private Context context; + private Map interceptorContext; + private Tag2Input input; + + public Tag2RequestInput(final APIGatewayProxyRequestEvent event, final Context context, final Map interceptorContext, final Tag2Input input) { + this.event = event; + this.context = context; + this.interceptorContext = interceptorContext; + this.input = input; + } + + /** + * Returns the typed request input, with path, query and body parameters + */ + public Tag2Input getInput() { + return this.input; + } + + /** + * Returns the raw API Gateway event + */ + public APIGatewayProxyRequestEvent getEvent() { + return this.event; + } + + /** + * Returns the lambda context + */ + public Context getContext() { + return this.context; + } + + /** + * Returns the interceptor context, which may contain values set by request interceptors + */ + public Map getInterceptorContext() { + return this.interceptorContext; + } + } + + /** + * Lambda handler wrapper for the tag2 operation + */ + public static abstract class Tag2 implements RequestHandler { + /** + * Handle the request for the tag2 operation + */ + public abstract Tag2Response handle(final Tag2RequestInput request); + + /** + * For more complex interceptors that require instantiation with parameters, you may override this method to + * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, + * prefer the @Interceptors annotation. + */ + public List> getInterceptors() { + return Collections.emptyList(); + } + + @Override + public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent event, final Context context) { + return this.handleRequestWithAdditionalInterceptors(event, context, new ArrayList<>()); + } + + public APIGatewayProxyResponseEvent handleRequestWithAdditionalInterceptors(final APIGatewayProxyRequestEvent event, final Context context, final List> additionalInterceptors) { + final Map interceptorContext = new HashMap<>(); + + List> interceptors = new ArrayList<>(); + interceptors.addAll(additionalInterceptors); + + List> annotationInterceptors = getAnnotationInterceptors(this.getClass()); + + interceptors.addAll(annotationInterceptors); + interceptors.addAll(this.getInterceptors()); + + final HandlerChain chain = buildHandlerChain(interceptors, new HandlerChain() { + @Override + public Response next(ChainedRequestInput input) { + return handle(new Tag2RequestInput(input.getEvent(), input.getContext(), input.getInterceptorContext(), input.getInput())); + } + }); + + final Response response = chain.next(new ChainedRequestInput() { + @Override + public HandlerChain getChain() { + // The chain's next method ignores the chain given as input, and is pre-built to follow the remaining + // chain. + return null; + } + + @Override + public APIGatewayProxyRequestEvent getEvent() { + return event; + } + + @Override + public Context getContext() { + return context; + } + + @Override + public Tag2Input getInput() { + return new Tag2Input(event); + } + + @Override + public Map getInterceptorContext() { + return interceptorContext; + } + }); + + return new APIGatewayProxyResponseEvent() + .withStatusCode(response.getStatusCode()) + .withHeaders(response.getHeaders()) + .withBody(response.getBody()); + } + } + + public static abstract class HandlerRouter implements RequestHandler { + private static final String neitherMethodAndPath = concatMethodAndPath(\\"GET\\", \\"/neither\\"); + private static final String bothMethodAndPath = concatMethodAndPath(\\"GET\\", \\"/both\\"); + private static final String tag1MethodAndPath = concatMethodAndPath(\\"GET\\", \\"/tag1\\"); + private static final String tag2MethodAndPath = concatMethodAndPath(\\"GET\\", \\"/tag2\\"); + + private final Neither constructedNeither; + private final Both constructedBoth; + private final Tag1 constructedTag1; + private final Tag2 constructedTag2; + + /** + * This method must return your implementation of the Neither operation + */ + public abstract Neither neither(); + /** + * This method must return your implementation of the Both operation + */ + public abstract Both both(); + /** + * This method must return your implementation of the Tag1 operation + */ + public abstract Tag1 tag1(); + /** + * This method must return your implementation of the Tag2 operation + */ + public abstract Tag2 tag2(); + + private static enum Route { + neitherRoute, + bothRoute, + tag1Route, + tag2Route, + } + + /** + * Map of method and path to the route to map to + */ + private final Map routes = new HashMap<>(); + + public HandlerRouter() { + this.routes.put(neitherMethodAndPath, Route.neitherRoute); + this.routes.put(bothMethodAndPath, Route.bothRoute); + this.routes.put(tag1MethodAndPath, Route.tag1Route); + this.routes.put(tag2MethodAndPath, Route.tag2Route); + // Handlers are all constructed in the router's constructor such that lambda behaviour remains consistent; + // ie resources created in the constructor remain in memory between invocations. + // https://docs.aws.amazon.com/lambda/latest/dg/java-handler.html + this.constructedNeither = this.neither(); + this.constructedBoth = this.both(); + this.constructedTag1 = this.tag1(); + this.constructedTag2 = this.tag2(); + } + + /** + * For more complex interceptors that require instantiation with parameters, you may override this method to + * return a list of instantiated interceptors. For simple interceptors with no need for constructor arguments, + * prefer the @Interceptors annotation. + */ + public List> getInterceptors() { + return Collections.emptyList(); + } + + @Override + public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent event, final Context context) { + String method = event.getRequestContext().getHttpMethod(); + String path = event.getRequestContext().getResourcePath(); + String methodAndPath = concatMethodAndPath(method, path); + Route route = this.routes.get(methodAndPath); + + switch (route) { + case neitherRoute: + List> neitherInterceptors = getAnnotationInterceptors(this.getClass()); + neitherInterceptors.addAll(this.getInterceptors()); + return this.constructedNeither.handleRequestWithAdditionalInterceptors(event, context, neitherInterceptors); + case bothRoute: + List> bothInterceptors = getAnnotationInterceptors(this.getClass()); + bothInterceptors.addAll(this.getInterceptors()); + return this.constructedBoth.handleRequestWithAdditionalInterceptors(event, context, bothInterceptors); + case tag1Route: + List> tag1Interceptors = getAnnotationInterceptors(this.getClass()); + tag1Interceptors.addAll(this.getInterceptors()); + return this.constructedTag1.handleRequestWithAdditionalInterceptors(event, context, tag1Interceptors); + case tag2Route: + List> tag2Interceptors = getAnnotationInterceptors(this.getClass()); + tag2Interceptors.addAll(this.getInterceptors()); + return this.constructedTag2.handleRequestWithAdditionalInterceptors(event, context, tag2Interceptors); + default: + throw new RuntimeException(String.format(\\"No registered handler for method {} and path {}\\", method, path)); + } + } + } +}", + "src/main/java/test/test/client/api/DefaultApi/OperationConfig.java": "package test.test.client.api; + +import test.test.client.model.*; + + +import java.util.HashMap; +import java.util.Map; + +// Generic type for object \\"keyed\\" by operation names +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +@lombok.Builder @lombok.Getter +public class OperationConfig { + private T neither; + private T both; + private T tag1; + private T tag2; + + public Map asMap() { + Map map = new HashMap<>(); + map.put(\\"neither\\", this.neither); + map.put(\\"both\\", this.both); + map.put(\\"tag1\\", this.tag1); + map.put(\\"tag2\\", this.tag2); + return map; + } +} +", + "src/main/java/test/test/client/api/DefaultApi/OperationLookup.java": "package test.test.client.api; + +import test.test.client.model.*; + + +import java.util.HashMap; +import java.util.Map; + + +// Look up path and http method for a given operation name +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public class OperationLookup { + /** + * Returns the operation lookup information for the OpenApiGatewayLambdaApi construct + */ + public static Map> getOperationLookup() { + final Map> config = new HashMap<>(); + + config.put(\\"neither\\", new HashMap() { { put(\\"path\\", \\"/neither\\"); put(\\"method\\", \\"GET\\"); } }); + config.put(\\"both\\", new HashMap() { { put(\\"path\\", \\"/both\\"); put(\\"method\\", \\"GET\\"); } }); + config.put(\\"tag1\\", new HashMap() { { put(\\"path\\", \\"/tag1\\"); put(\\"method\\", \\"GET\\"); } }); + config.put(\\"tag2\\", new HashMap() { { put(\\"path\\", \\"/tag2\\"); put(\\"method\\", \\"GET\\"); } }); + + return config; + } +} +", + "src/main/java/test/test/client/api/DefaultApi/Operations.java": "package test.test.client.api; + +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public class Operations { + /** + * Returns an OperationConfig Builder with all values populated with the given value. + * You can override specific values on the builder if you like. + * Make sure you call \`.build()\` at the end to construct the OperationConfig. + */ + public static OperationConfig.OperationConfigBuilder all(final T value) { + return OperationConfig.builder() + .neither(value) + .both(value) + .tag1(value) + .tag2(value) + ; + } +} +", + "src/main/java/test/test/client/api/Tag1Api.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client.api; + +import test.test.client.ApiCallback; +import test.test.client.ApiClient; +import test.test.client.ApiException; +import test.test.client.ApiResponse; +import test.test.client.Configuration; +import test.test.client.Pair; +import test.test.client.ProgressRequestBody; +import test.test.client.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.ws.rs.core.GenericType; + +public class Tag1Api { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public Tag1Api() { + this(Configuration.getDefaultApiClient()); + } + + public Tag1Api(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + private okhttp3.Call bothCall(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = \\"/both\\"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put(\\"Accept\\", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put(\\"Content-Type\\", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, \\"GET\\", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings(\\"rawtypes\\") + private okhttp3.Call bothValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return bothCall(_callback); + + } + + + private ApiResponse bothWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = bothValidateBeforeCall(null); + return localVarApiClient.execute(localVarCall); + } + + private okhttp3.Call bothAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = bothValidateBeforeCall(_callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + public class APIbothRequest { + + private APIbothRequest() { + } + + /** + * Build call for both + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return bothCall(_callback); + } + + /** + * Execute both request + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public void execute() throws ApiException { + bothWithHttpInfo(); + } + + /** + * Execute both request with HTTP info returned + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return bothWithHttpInfo(); + } + + /** + * Execute both request (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return bothAsync(_callback); + } + } + + /** + * + * + * @return APIbothRequest + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public APIbothRequest both() { + return new APIbothRequest(); + } + private okhttp3.Call tag1Call(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = \\"/tag1\\"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put(\\"Accept\\", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put(\\"Content-Type\\", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, \\"GET\\", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings(\\"rawtypes\\") + private okhttp3.Call tag1ValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return tag1Call(_callback); + + } + + + private ApiResponse tag1WithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = tag1ValidateBeforeCall(null); + return localVarApiClient.execute(localVarCall); + } + + private okhttp3.Call tag1Async(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = tag1ValidateBeforeCall(_callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + public class APItag1Request { + + private APItag1Request() { + } + + /** + * Build call for tag1 + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return tag1Call(_callback); + } + + /** + * Execute tag1 request + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public void execute() throws ApiException { + tag1WithHttpInfo(); + } + + /** + * Execute tag1 request with HTTP info returned + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return tag1WithHttpInfo(); + } + + /** + * Execute tag1 request (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return tag1Async(_callback); + } + } + + /** + * + * + * @return APItag1Request + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public APItag1Request tag1() { + return new APItag1Request(); + } +} +", + "src/main/java/test/test/client/api/Tag2Api.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client.api; + +import test.test.client.ApiCallback; +import test.test.client.ApiClient; +import test.test.client.ApiException; +import test.test.client.ApiResponse; +import test.test.client.Configuration; +import test.test.client.Pair; +import test.test.client.ProgressRequestBody; +import test.test.client.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.ws.rs.core.GenericType; + +public class Tag2Api { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public Tag2Api() { + this(Configuration.getDefaultApiClient()); + } + + public Tag2Api(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + private okhttp3.Call tag2Call(final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = \\"/tag2\\"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put(\\"Accept\\", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put(\\"Content-Type\\", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, \\"GET\\", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings(\\"rawtypes\\") + private okhttp3.Call tag2ValidateBeforeCall(final ApiCallback _callback) throws ApiException { + return tag2Call(_callback); + + } + + + private ApiResponse tag2WithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = tag2ValidateBeforeCall(null); + return localVarApiClient.execute(localVarCall); + } + + private okhttp3.Call tag2Async(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = tag2ValidateBeforeCall(_callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + public class APItag2Request { + + private APItag2Request() { + } + + /** + * Build call for tag2 + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return tag2Call(_callback); + } + + /** + * Execute tag2 request + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public void execute() throws ApiException { + tag2WithHttpInfo(); + } + + /** + * Execute tag2 request with HTTP info returned + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return tag2WithHttpInfo(); + } + + /** + * Execute tag2 request (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return tag2Async(_callback); + } + } + + /** + * + * + * @return APItag2Request + * @http.response.details + + + +
Status Code Description Response Headers
200 Ok -
+ */ + public APItag2Request tag2() { + return new APItag2Request(); + } +} +", + "src/main/java/test/test/client/auth/ApiKeyAuth.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client.auth; + +import test.test.client.ApiException; +import test.test.client.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + \\" \\" + apiKey; + } else { + value = apiKey; + } + if (\\"query\\".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if (\\"header\\".equals(location)) { + headerParams.put(paramName, value); + } else if (\\"cookie\\".equals(location)) { + cookieParams.put(paramName, value); + } + } +} +", + "src/main/java/test/test/client/auth/Authentication.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client.auth; + +import test.test.client.Pair; +import test.test.client.ApiException; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +public interface Authentication { + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters + */ + void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; +} +", + "src/main/java/test/test/client/auth/HttpBasicAuth.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client.auth; + +import test.test.client.Pair; +import test.test.client.ApiException; + +import okhttp3.Credentials; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +import java.io.UnsupportedEncodingException; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (username == null && password == null) { + return; + } + headerParams.put(\\"Authorization\\", Credentials.basic( + username == null ? \\"\\" : username, + password == null ? \\"\\" : password)); + } +} +", + "src/main/java/test/test/client/auth/HttpBearerAuth.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client.auth; + +import test.test.client.ApiException; +import test.test.client.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public class HttpBearerAuth implements Authentication { + private final String scheme; + private String bearerToken; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() { + return bearerToken; + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.bearerToken = bearerToken; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (bearerToken == null) { + return; + } + + headerParams.put(\\"Authorization\\", (scheme != null ? upperCaseBearer(scheme) + \\" \\" : \\"\\") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return (\\"bearer\\".equalsIgnoreCase(scheme)) ? \\"Bearer\\" : scheme; + } +} +", + "src/main/java/test/test/client/model/AbstractOpenApiSchema.java": "/* + * Multiple Tags Test + * 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. + */ + + +package test.test.client.model; + +import test.test.client.ApiException; +import java.util.Objects; +import java.lang.reflect.Type; +import java.util.Map; +import javax.ws.rs.core.GenericType; + +//import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@lombok.AllArgsConstructor @lombok.experimental.SuperBuilder +@javax.annotation.Generated(value = \\"org.openapitools.codegen.languages.JavaClientCodegen\\") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + //@JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(\\"class \\").append(getClass()).append(\\" {\\\\n\\"); + sb.append(\\" instance: \\").append(toIndentedString(instance)).append(\\"\\\\n\\"); + sb.append(\\" isNullable: \\").append(toIndentedString(isNullable)).append(\\"\\\\n\\"); + sb.append(\\" schemaType: \\").append(toIndentedString(schemaType)).append(\\"\\\\n\\"); + sb.append(\\"}\\"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return \\"null\\"; + } + return o.toString().replace(\\"\\\\n\\", \\"\\\\n \\"); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} +", + "src/test/java/org/acme/MyTest.java": "package org.acme; + +import org.junit.jupiter.api.Test; + +public class MyTest { + @Test + public void testHello() { + System.out.println(\\"Hello, world!\\"); + } +}", + "src/test/java/test/test/client/api/DefaultApiTest.java": "/* + * Multiple Tags Test * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 @@ -7281,47 +15082,39 @@ public class ApiErrorTest { */ -package test.test.client.model; +package test.test.client.api; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; -import java.math.BigDecimal; +import test.test.client.ApiException; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** - * Model tests for TestRequest + * API tests for DefaultApi */ -public class TestRequestTest { - private final TestRequest model = new TestRequest(); +@Disabled +public class DefaultApiTest { - /** - * Model tests for TestRequest - */ - @Test - public void testTestRequest() { - // TODO: test TestRequest - } + private final DefaultApi api = new DefaultApi(); /** - * Test the property 'myInput' + * @throws ApiException if the Api call fails */ @Test - public void myInputTest() { - // TODO: test myInput + public void neitherTest() throws ApiException { + api.neither() + .execute(); + // TODO: test validations } } ", - "src/test/java/test/test/client/model/TestResponseMessagesInnerTest.java": "/* - * Example API + "src/test/java/test/test/client/api/Tag1ApiTest.java": "/* + * Multiple Tags Test * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 @@ -7333,54 +15126,49 @@ public class TestRequestTest { */ -package test.test.client.model; +package test.test.client.api; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; +import test.test.client.ApiException; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** - * Model tests for TestResponseMessagesInner + * API tests for Tag1Api */ -public class TestResponseMessagesInnerTest { - private final TestResponseMessagesInner model = new TestResponseMessagesInner(); +@Disabled +public class Tag1ApiTest { - /** - * Model tests for TestResponseMessagesInner - */ - @Test - public void testTestResponseMessagesInner() { - // TODO: test TestResponseMessagesInner - } + private final Tag1Api api = new Tag1Api(); /** - * Test the property 'message' + * @throws ApiException if the Api call fails */ @Test - public void messageTest() { - // TODO: test message + public void bothTest() throws ApiException { + api.both() + .execute(); + // TODO: test validations } /** - * Test the property 'id' + * @throws ApiException if the Api call fails */ @Test - public void idTest() { - // TODO: test id + public void tag1Test() throws ApiException { + api.tag1() + .execute(); + // TODO: test validations } } ", - "src/test/java/test/test/client/model/TestResponseTest.java": "/* - * Example API + "src/test/java/test/test/client/api/Tag2ApiTest.java": "/* + * Multiple Tags Test * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 @@ -7392,43 +15180,33 @@ public class TestResponseMessagesInnerTest { */ -package test.test.client.model; +package test.test.client.api; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import test.test.client.model.TestResponseMessagesInner; +import test.test.client.ApiException; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** - * Model tests for TestResponse + * API tests for Tag2Api */ -public class TestResponseTest { - private final TestResponse model = new TestResponse(); +@Disabled +public class Tag2ApiTest { - /** - * Model tests for TestResponse - */ - @Test - public void testTestResponse() { - // TODO: test TestResponse - } + private final Tag2Api api = new Tag2Api(); /** - * Test the property 'messages' + * @throws ApiException if the Api call fails */ @Test - public void messagesTest() { - // TODO: test messages + public void tag2Test() throws ApiException { + api.tag2() + .execute(); + // TODO: test validations } } @@ -7436,8 +15214,6 @@ public class TestResponseTest { } `; -exports[`Generated Java Client Code Unit Tests Multiple Tags 1`] = `"Operations with multiple tags are not yet supported, please tag operations with at most one tag. The following operations have multiple tags: get /both"`; - exports[`Generated Java Client Code Unit Tests Single 1`] = ` Object { ".gitattributes": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". @@ -7611,7 +15387,7 @@ src/test/java/test/test/client/model/TestRequestTest.java src/test/java/test/test/client/model/TestResponseMessagesInnerTest.java src/test/java/test/test/client/model/TestResponseTest.java ", - ".openapi-generator/VERSION": "6.0.1", + ".openapi-generator/VERSION": "6.3.0", ".projen/deps.json": Object { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", "dependencies": Array [ @@ -8168,19 +15944,11 @@ components: - errorMessage type: object TestRequest: - example: - myInput: 0.8008281904610115 properties: myInput: type: number type: object TestResponse: - example: - messages: - - id: 0 - message: message - - id: 0 - message: message properties: messages: items: @@ -8190,9 +15958,6 @@ components: - messages type: object TestResponse_messages_inner: - example: - id: 0 - message: message properties: message: type: string @@ -8218,7 +15983,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.3.0' + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' } } @@ -8270,7 +16035,7 @@ if(hasProperty('target') && target == 'android') { task.from variant.javaCompile.destinationDir task.destinationDir = project.file(\\"\${project.buildDir}/outputs/jar\\") task.archiveName = \\"\${project.name}-\${variant.baseName}-\${version}.jar\\" - artifacts.add('archives', task); + artifacts.add('archives', task) } } @@ -8311,20 +16076,20 @@ ext { } dependencies { - implementation 'io.swagger:swagger-annotations:1.6.5' + implementation 'io.swagger:swagger-annotations:1.6.8' implementation \\"com.google.code.findbugs:jsr305:3.0.2\\" - implementation 'com.squareup.okhttp3:okhttp:4.9.3' - implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3' - implementation 'com.google.code.gson:gson:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.10.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' + implementation 'com.google.code.gson:gson:2.9.1' implementation 'io.gsonfire:gson-fire:1.8.5' implementation 'javax.ws.rs:jsr311-api:1.1.1' implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1' - implementation 'org.openapitools:jackson-databind-nullable:0.2.3' + implementation 'org.openapitools:jackson-databind-nullable:0.2.4' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' implementation \\"jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version\\" - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1' testImplementation 'org.mockito:mockito-core:3.12.4' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1' } javadoc { @@ -8384,19 +16149,20 @@ test { resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( \\"io.swagger\\" % \\"swagger-annotations\\" % \\"1.6.5\\", - \\"com.squareup.okhttp3\\" % \\"okhttp\\" % \\"4.9.3\\", - \\"com.squareup.okhttp3\\" % \\"logging-interceptor\\" % \\"4.9.3\\", - \\"com.google.code.gson\\" % \\"gson\\" % \\"2.9.0\\", + \\"com.squareup.okhttp3\\" % \\"okhttp\\" % \\"4.10.0\\", + \\"com.squareup.okhttp3\\" % \\"logging-interceptor\\" % \\"4.10.0\\", + \\"com.google.code.gson\\" % \\"gson\\" % \\"2.9.1\\", \\"org.apache.commons\\" % \\"commons-lang3\\" % \\"3.12.0\\", \\"javax.ws.rs\\" % \\"jsr311-api\\" % \\"1.1.1\\", \\"javax.ws.rs\\" % \\"javax.ws.rs-api\\" % \\"2.1.1\\", - \\"org.openapitools\\" % \\"jackson-databind-nullable\\" % \\"0.2.3\\", + \\"org.openapitools\\" % \\"jackson-databind-nullable\\" % \\"0.2.4\\", \\"io.gsonfire\\" % \\"gson-fire\\" % \\"1.8.5\\" % \\"compile\\", \\"jakarta.annotation\\" % \\"jakarta.annotation-api\\" % \\"1.3.5\\" % \\"compile\\", \\"com.google.code.findbugs\\" % \\"jsr305\\" % \\"3.0.2\\" % \\"compile\\", \\"jakarta.annotation\\" % \\"jakarta.annotation-api\\" % \\"1.3.5\\" % \\"compile\\", - \\"org.junit.jupiter\\" % \\"junit-jupiter-api\\" % \\"5.8.2\\" % \\"test\\", - \\"com.novocode\\" % \\"junit-interface\\" % \\"0.10\\" % \\"test\\" + \\"org.junit.jupiter\\" % \\"junit-jupiter-api\\" % \\"5.9.1\\" % \\"test\\", + \\"com.novocode\\" % \\"junit-interface\\" % \\"0.10\\" % \\"test\\", + \\"org.mockito\\" % \\"mockito-core\\" % \\"3.12.4\\" % \\"test\\" ) ) ", @@ -9772,7 +17538,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-enforcer-plugin - 3.0.0 + 3.1.0 enforce-maven @@ -9815,6 +17581,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal maven-dependency-plugin + 3.3.0 package @@ -9831,7 +17598,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-jar-plugin - 3.2.0 + 3.3.0 @@ -9845,7 +17612,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.codehaus.mojo build-helper-maven-plugin - 3.2.0 + 3.3.0 add_sources @@ -9876,7 +17643,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-javadoc-plugin - 3.3.2 + 3.4.1 attach-javadocs @@ -9899,7 +17666,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-source-plugin - 3.2.0 + 3.2.1 attach-sources @@ -9979,11 +17746,6 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal - - io.swagger - swagger-annotations - \${swagger-core-version} - com.google.code.findbugs @@ -10026,6 +17788,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal jackson-databind-nullable \${jackson-databind-nullable-version} + javax.ws.rs jsr311-api @@ -10061,19 +17824,19 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal \${java.version} \${java.version} 1.8.5 - 1.6.5 - 4.9.3 - 2.9.0 + 1.6.6 + 4.10.0 + 2.9.1 3.12.0 - 0.2.3 + 0.2.4 1.3.5 - 5.8.2 - 1.6.2 + 5.9.1 + 1.9.1 3.12.4 2.1.1 1.1.1 UTF-8 - 2.21.0 + 2.27.2 ", @@ -10215,6 +17978,15 @@ import test.test.client.auth.ApiKeyAuth; public class ApiClient { private String basePath = \\"http://localhost\\"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + \\"\\", + \\"No description provided\\", + new HashMap() + ) + )); + protected Integer serverIndex = 0; + protected Map serverVariables = null; private boolean debugging = false; private Map defaultHeaderMap = new HashMap(); private Map defaultCookieMap = new HashMap(); @@ -10308,6 +18080,33 @@ public class ApiClient { return this; } + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + /** * Get HTTP client * @@ -10432,7 +18231,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setDateFormat(DateFormat dateFormat) { - this.json.setDateFormat(dateFormat); + JSON.setDateFormat(dateFormat); return this; } @@ -10443,7 +18242,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setSqlDateFormat(DateFormat dateFormat) { - this.json.setSqlDateFormat(dateFormat); + JSON.setSqlDateFormat(dateFormat); return this; } @@ -10454,7 +18253,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - this.json.setOffsetDateTimeFormat(dateFormat); + JSON.setOffsetDateTimeFormat(dateFormat); return this; } @@ -10465,7 +18264,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { - this.json.setLocalDateFormat(dateFormat); + JSON.setLocalDateFormat(dateFormat); return this; } @@ -10476,7 +18275,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setLenientOnJson(boolean lenientOnJson) { - this.json.setLenientOnJson(lenientOnJson); + JSON.setLenientOnJson(lenientOnJson); return this; } @@ -10569,6 +18368,18 @@ public class ApiClient { throw new RuntimeException(\\"No OAuth2 authentication configured!\\"); } + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException(\\"No AWS4 authentication configured!\\"); + } + /** * Set the User-Agent header's value (by adding to the default header map). * @@ -10737,7 +18548,7 @@ public class ApiClient { return \\"\\"; } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { //Serialize to json string and remove the \\" enclosing characters - String jsonStr = json.serialize(param); + String jsonStr = JSON.serialize(param); return jsonStr.substring(1, jsonStr.length() - 1); } else if (param instanceof Collection) { StringBuilder b = new StringBuilder(); @@ -10745,7 +18556,7 @@ public class ApiClient { if (b.length() > 0) { b.append(\\",\\"); } - b.append(String.valueOf(o)); + b.append(o); } return b.toString(); } else { @@ -10996,7 +18807,7 @@ public class ApiClient { contentType = \\"application/json\\"; } if (isJsonMime(contentType)) { - return json.deserialize(respBody, returnType); + return JSON.deserialize(respBody, returnType); } else if (returnType.equals(String.class)) { // Expecting string, return the raw response body. return (T) respBody; @@ -11030,11 +18841,13 @@ public class ApiClient { } else if (isJsonMime(contentType)) { String content; if (obj != null) { - content = json.serialize(obj); + content = JSON.serialize(obj); } else { content = null; } return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); } else { throw new ApiException(\\"Content type \\\\\\"\\" + contentType + \\"\\\\\\" is not supported\\"); } @@ -11325,7 +19138,18 @@ public class ApiClient { if (baseUrl != null) { url.append(baseUrl).append(path); } else { - url.append(basePath).append(path); + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + \\"Invalid index %d when selecting the host settings. Must be less than %d\\", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); } if (queryParams != null && !queryParams.isEmpty()) { @@ -11454,11 +19278,12 @@ public class ApiClient { for (Object item: list) { if (item instanceof File) { addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); } } } else { - Headers partHeaders = Headers.of(\\"Content-Disposition\\", \\"form-data; name=\\\\\\"\\" + param.getKey() + \\"\\\\\\"\\"); - mpBuilder.addPart(partHeaders, RequestBody.create(parameterToString(param.getValue()), null)); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); } } return mpBuilder.build(); @@ -11492,6 +19317,31 @@ public class ApiClient { mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); } + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse(\\"text/plain\\")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse(\\"application/json\\")); + } + + Headers partHeaders = Headers.of(\\"Content-Disposition\\", \\"form-data; name=\\\\\\"\\" + key + \\"\\\\\\"\\"); + mpBuilder.addPart(partHeaders, requestBody); + } + /** * Get network interceptor to add it to the httpClient to track download progress for * async requests. @@ -11559,7 +19409,7 @@ public class ApiClient { KeyStore caKeyStore = newEmptyKeyStore(password); int index = 0; for (Certificate certificate : certificates) { - String certificateAlias = \\"ca\\" + Integer.toString(index++); + String certificateAlias = \\"ca\\" + (index++); caKeyStore.setCertificateEntry(certificateAlias, certificate); } trustManagerFactory.init(caKeyStore); @@ -11592,7 +19442,7 @@ public class ApiClient { /** * Convert the HTTP request body to a string. * - * @param request The HTTP request object + * @param requestBody The HTTP request object * @return The string representation of the HTTP request body * @throws test.test.client.ApiException If fail to serialize the request body object into a string */ @@ -11713,7 +19563,7 @@ public class ApiException extends Exception { * @param responseBody the response body */ public ApiException(int code, Map> responseHeaders, String responseBody) { - this((String) null, (Throwable) null, code, responseHeaders, responseBody); + this(\\"Response Code: \\" + code + \\" Response Body: \\" + responseBody, (Throwable) null, code, responseHeaders, responseBody); } /** @@ -12634,7 +20484,7 @@ public class ServerConfiguration { throw new IllegalArgumentException(\\"The variable \\" + name + \\" in the server URL has invalid value \\" + value + \\".\\"); } } - url = url.replaceAll(\\"\\\\\\\\{\\" + name + \\"\\\\\\\\}\\", value); + url = url.replace(\\"{\\" + name + \\"}\\", value); } return url; } @@ -12883,10 +20733,7 @@ public class DefaultApi { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call anyRequestResponseValidateBeforeCall(Object body, final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = anyRequestResponseCall(body, _callback); - return localVarCall; + return anyRequestResponseCall(body, _callback); } @@ -13020,7 +20867,6 @@ public class DefaultApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -13028,7 +20874,6 @@ public class DefaultApi { } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { @@ -13041,10 +20886,7 @@ public class DefaultApi { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call emptyValidateBeforeCall(final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = emptyCall(_callback); - return localVarCall; + return emptyCall(_callback); } @@ -13184,15 +21026,12 @@ public class DefaultApi { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call mediaTypesValidateBeforeCall(File body, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'body' is set if (body == null) { throw new ApiException(\\"Missing the required parameter 'body' when calling mediaTypes(Async)\\"); } - - okhttp3.Call localVarCall = mediaTypesCall(body, _callback); - return localVarCall; + return mediaTypesCall(body, _callback); } @@ -13310,7 +21149,7 @@ public class DefaultApi { // create path and map variables String localVarPath = \\"/path/{pathParam}\\" - .replaceAll(\\"\\\\\\\\{\\" + \\"pathParam\\" + \\"\\\\\\\\}\\", localVarApiClient.escapeString(pathParam.toString())); + .replace(\\"{\\" + \\"pathParam\\" + \\"}\\", localVarApiClient.escapeString(pathParam.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -13356,35 +21195,32 @@ public class DefaultApi { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call operationOneValidateBeforeCall(String param1, List param2, BigDecimal param3, String pathParam, TestRequest testRequest, String param4, final ApiCallback _callback) throws ApiException { - // verify the required parameter 'param1' is set if (param1 == null) { throw new ApiException(\\"Missing the required parameter 'param1' when calling operationOne(Async)\\"); } - + // verify the required parameter 'param2' is set if (param2 == null) { throw new ApiException(\\"Missing the required parameter 'param2' when calling operationOne(Async)\\"); } - + // verify the required parameter 'param3' is set if (param3 == null) { throw new ApiException(\\"Missing the required parameter 'param3' when calling operationOne(Async)\\"); } - + // verify the required parameter 'pathParam' is set if (pathParam == null) { throw new ApiException(\\"Missing the required parameter 'pathParam' when calling operationOne(Async)\\"); } - + // verify the required parameter 'testRequest' is set if (testRequest == null) { throw new ApiException(\\"Missing the required parameter 'testRequest' when calling operationOne(Async)\\"); } - - okhttp3.Call localVarCall = operationOneCall(param1, param2, param3, pathParam, testRequest, param4, _callback); - return localVarCall; + return operationOneCall(param1, param2, param3, pathParam, testRequest, param4, _callback); } @@ -13546,7 +21382,6 @@ public class DefaultApi { } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { @@ -13559,10 +21394,7 @@ public class DefaultApi { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call withoutOperationIdDeleteValidateBeforeCall(final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = withoutOperationIdDeleteCall(_callback); - return localVarCall; + return withoutOperationIdDeleteCall(_callback); } @@ -15679,8 +23511,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -15697,6 +23527,7 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -15713,7 +23544,7 @@ public class ApiError { @SerializedName(SERIALIZED_NAME_ERROR_MESSAGE) private String errorMessage; - public ApiError() { + public ApiError() { } public ApiError errorMessage(String errorMessage) { @@ -15727,7 +23558,6 @@ public class ApiError { * @return errorMessage **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = \\"\\") public String getErrorMessage() { return errorMessage; @@ -15799,9 +23629,7 @@ public class ApiError { */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj == null) { - if (ApiError.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields + if (!ApiError.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null throw new IllegalArgumentException(String.format(\\"The required field(s) %s in ApiError is not found in the empty JSON string\\", ApiError.openapiRequiredFields.toString())); } } @@ -15820,7 +23648,7 @@ public class ApiError { throw new IllegalArgumentException(String.format(\\"The required field \`%s\` is not found in the JSON string: %s\\", requiredField, jsonObj.toString())); } } - if (jsonObj.get(\\"errorMessage\\") != null && !jsonObj.get(\\"errorMessage\\").isJsonPrimitive()) { + if (!jsonObj.get(\\"errorMessage\\").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(\\"Expected the field \`errorMessage\` to be a primitive type in the JSON string but got \`%s\`\\", jsonObj.get(\\"errorMessage\\").toString())); } } @@ -15898,8 +23726,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.math.BigDecimal; @@ -15917,6 +23743,7 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -15933,7 +23760,7 @@ public class TestRequest { @SerializedName(SERIALIZED_NAME_MY_INPUT) private BigDecimal myInput; - public TestRequest() { + public TestRequest() { } public TestRequest myInput(BigDecimal myInput) { @@ -15947,7 +23774,6 @@ public class TestRequest { * @return myInput **/ @javax.annotation.Nullable - @ApiModelProperty(value = \\"\\") public BigDecimal getMyInput() { return myInput; @@ -16018,9 +23844,7 @@ public class TestRequest { */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj == null) { - if (TestRequest.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields + if (!TestRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null throw new IllegalArgumentException(String.format(\\"The required field(s) %s in TestRequest is not found in the empty JSON string\\", TestRequest.openapiRequiredFields.toString())); } } @@ -16107,8 +23931,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -16128,6 +23950,7 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -16144,7 +23967,7 @@ public class TestResponse { @SerializedName(SERIALIZED_NAME_MESSAGES) private List messages = new ArrayList<>(); - public TestResponse() { + public TestResponse() { } public TestResponse messages(List messages) { @@ -16163,7 +23986,6 @@ public class TestResponse { * @return messages **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = \\"\\") public List getMessages() { return messages; @@ -16235,9 +24057,7 @@ public class TestResponse { */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj == null) { - if (TestResponse.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields + if (!TestResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null throw new IllegalArgumentException(String.format(\\"The required field(s) %s in TestResponse is not found in the empty JSON string\\", TestResponse.openapiRequiredFields.toString())); } } @@ -16256,18 +24076,16 @@ public class TestResponse { throw new IllegalArgumentException(String.format(\\"The required field \`%s\` is not found in the JSON string: %s\\", requiredField, jsonObj.toString())); } } - JsonArray jsonArraymessages = jsonObj.getAsJsonArray(\\"messages\\"); - if (jsonArraymessages != null) { - // ensure the json data is an array - if (!jsonObj.get(\\"messages\\").isJsonArray()) { - throw new IllegalArgumentException(String.format(\\"Expected the field \`messages\` to be an array in the JSON string but got \`%s\`\\", jsonObj.get(\\"messages\\").toString())); - } - - // validate the optional field \`messages\` (array) - for (int i = 0; i < jsonArraymessages.size(); i++) { - TestResponseMessagesInner.validateJsonObject(jsonArraymessages.get(i).getAsJsonObject()); - }; + // ensure the json data is an array + if (!jsonObj.get(\\"messages\\").isJsonArray()) { + throw new IllegalArgumentException(String.format(\\"Expected the field \`messages\` to be an array in the JSON string but got \`%s\`\\", jsonObj.get(\\"messages\\").toString())); } + + JsonArray jsonArraymessages = jsonObj.getAsJsonArray(\\"messages\\"); + // validate the required field \`messages\` (array) + for (int i = 0; i < jsonArraymessages.size(); i++) { + TestResponseMessagesInner.validateJsonObject(jsonArraymessages.get(i).getAsJsonObject()); + }; } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @@ -16343,8 +24161,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import com.google.gson.Gson; @@ -16361,6 +24177,7 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -16381,7 +24198,7 @@ public class TestResponseMessagesInner { @SerializedName(SERIALIZED_NAME_ID) private Integer id; - public TestResponseMessagesInner() { + public TestResponseMessagesInner() { } public TestResponseMessagesInner message(String message) { @@ -16395,7 +24212,6 @@ public class TestResponseMessagesInner { * @return message **/ @javax.annotation.Nullable - @ApiModelProperty(value = \\"\\") public String getMessage() { return message; @@ -16418,7 +24234,6 @@ public class TestResponseMessagesInner { * @return id **/ @javax.annotation.Nonnull - @ApiModelProperty(required = true, value = \\"\\") public Integer getId() { return id; @@ -16493,9 +24308,7 @@ public class TestResponseMessagesInner { */ public static void validateJsonObject(JsonObject jsonObj) throws IOException { if (jsonObj == null) { - if (TestResponseMessagesInner.openapiRequiredFields.isEmpty()) { - return; - } else { // has required fields + if (!TestResponseMessagesInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null throw new IllegalArgumentException(String.format(\\"The required field(s) %s in TestResponseMessagesInner is not found in the empty JSON string\\", TestResponseMessagesInner.openapiRequiredFields.toString())); } } @@ -16514,7 +24327,7 @@ public class TestResponseMessagesInner { throw new IllegalArgumentException(String.format(\\"The required field \`%s\` is not found in the JSON string: %s\\", requiredField, jsonObj.toString())); } } - if (jsonObj.get(\\"message\\") != null && !jsonObj.get(\\"message\\").isJsonPrimitive()) { + if ((jsonObj.get(\\"message\\") != null && !jsonObj.get(\\"message\\").isJsonNull()) && !jsonObj.get(\\"message\\").isJsonPrimitive()) { throw new IllegalArgumentException(String.format(\\"Expected the field \`message\` to be a primitive type in the JSON string but got \`%s\`\\", jsonObj.get(\\"message\\").toString())); } } @@ -16699,8 +24512,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -16750,8 +24561,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.math.BigDecimal; import org.junit.jupiter.api.Disabled; @@ -16802,8 +24611,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -16861,8 +24668,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -17065,7 +24870,7 @@ src/test/java/test/test/client/api/DefaultApiTest.java src/test/java/test/test/client/api/Tag1ApiTest.java src/test/java/test/test/client/api/Tag2ApiTest.java ", - ".openapi-generator/VERSION": "6.0.1", + ".openapi-generator/VERSION": "6.3.0", ".projen/deps.json": Object { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", "dependencies": Array [ @@ -17544,7 +25349,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:2.3.+' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' - classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.3.0' + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' } } @@ -17596,7 +25401,7 @@ if(hasProperty('target') && target == 'android') { task.from variant.javaCompile.destinationDir task.destinationDir = project.file(\\"\${project.buildDir}/outputs/jar\\") task.archiveName = \\"\${project.name}-\${variant.baseName}-\${version}.jar\\" - artifacts.add('archives', task); + artifacts.add('archives', task) } } @@ -17637,20 +25442,20 @@ ext { } dependencies { - implementation 'io.swagger:swagger-annotations:1.6.5' + implementation 'io.swagger:swagger-annotations:1.6.8' implementation \\"com.google.code.findbugs:jsr305:3.0.2\\" - implementation 'com.squareup.okhttp3:okhttp:4.9.3' - implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3' - implementation 'com.google.code.gson:gson:2.9.0' + implementation 'com.squareup.okhttp3:okhttp:4.10.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' + implementation 'com.google.code.gson:gson:2.9.1' implementation 'io.gsonfire:gson-fire:1.8.5' implementation 'javax.ws.rs:jsr311-api:1.1.1' implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1' - implementation 'org.openapitools:jackson-databind-nullable:0.2.3' + implementation 'org.openapitools:jackson-databind-nullable:0.2.4' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' implementation \\"jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version\\" - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1' testImplementation 'org.mockito:mockito-core:3.12.4' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1' } javadoc { @@ -17710,19 +25515,20 @@ test { resolvers += Resolver.mavenLocal, libraryDependencies ++= Seq( \\"io.swagger\\" % \\"swagger-annotations\\" % \\"1.6.5\\", - \\"com.squareup.okhttp3\\" % \\"okhttp\\" % \\"4.9.3\\", - \\"com.squareup.okhttp3\\" % \\"logging-interceptor\\" % \\"4.9.3\\", - \\"com.google.code.gson\\" % \\"gson\\" % \\"2.9.0\\", + \\"com.squareup.okhttp3\\" % \\"okhttp\\" % \\"4.10.0\\", + \\"com.squareup.okhttp3\\" % \\"logging-interceptor\\" % \\"4.10.0\\", + \\"com.google.code.gson\\" % \\"gson\\" % \\"2.9.1\\", \\"org.apache.commons\\" % \\"commons-lang3\\" % \\"3.12.0\\", \\"javax.ws.rs\\" % \\"jsr311-api\\" % \\"1.1.1\\", \\"javax.ws.rs\\" % \\"javax.ws.rs-api\\" % \\"2.1.1\\", - \\"org.openapitools\\" % \\"jackson-databind-nullable\\" % \\"0.2.3\\", + \\"org.openapitools\\" % \\"jackson-databind-nullable\\" % \\"0.2.4\\", \\"io.gsonfire\\" % \\"gson-fire\\" % \\"1.8.5\\" % \\"compile\\", \\"jakarta.annotation\\" % \\"jakarta.annotation-api\\" % \\"1.3.5\\" % \\"compile\\", \\"com.google.code.findbugs\\" % \\"jsr305\\" % \\"3.0.2\\" % \\"compile\\", \\"jakarta.annotation\\" % \\"jakarta.annotation-api\\" % \\"1.3.5\\" % \\"compile\\", - \\"org.junit.jupiter\\" % \\"junit-jupiter-api\\" % \\"5.8.2\\" % \\"test\\", - \\"com.novocode\\" % \\"junit-interface\\" % \\"0.10\\" % \\"test\\" + \\"org.junit.jupiter\\" % \\"junit-jupiter-api\\" % \\"5.9.1\\" % \\"test\\", + \\"com.novocode\\" % \\"junit-interface\\" % \\"0.10\\" % \\"test\\", + \\"org.mockito\\" % \\"mockito-core\\" % \\"3.12.4\\" % \\"test\\" ) ) ", @@ -18973,7 +26779,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-enforcer-plugin - 3.0.0 + 3.1.0 enforce-maven @@ -19016,6 +26822,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal maven-dependency-plugin + 3.3.0 package @@ -19032,7 +26839,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-jar-plugin - 3.2.0 + 3.3.0 @@ -19046,7 +26853,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.codehaus.mojo build-helper-maven-plugin - 3.2.0 + 3.3.0 add_sources @@ -19077,7 +26884,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-javadoc-plugin - 3.3.2 + 3.4.1 attach-javadocs @@ -19100,7 +26907,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal org.apache.maven.plugins maven-source-plugin - 3.2.0 + 3.2.1 attach-sources @@ -19180,11 +26987,6 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal - - io.swagger - swagger-annotations - \${swagger-core-version} - com.google.code.findbugs @@ -19227,6 +27029,7 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal jackson-databind-nullable \${jackson-databind-nullable-version} + javax.ws.rs jsr311-api @@ -19262,19 +27065,19 @@ if \\"%OS%\\"==\\"Windows_NT\\" endlocal \${java.version} \${java.version} 1.8.5 - 1.6.5 - 4.9.3 - 2.9.0 + 1.6.6 + 4.10.0 + 2.9.1 3.12.0 - 0.2.3 + 0.2.4 1.3.5 - 5.8.2 - 1.6.2 + 5.9.1 + 1.9.1 3.12.4 2.1.1 1.1.1 UTF-8 - 2.21.0 + 2.27.2 ", @@ -19416,6 +27219,15 @@ import test.test.client.auth.ApiKeyAuth; public class ApiClient { private String basePath = \\"http://localhost\\"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + \\"\\", + \\"No description provided\\", + new HashMap() + ) + )); + protected Integer serverIndex = 0; + protected Map serverVariables = null; private boolean debugging = false; private Map defaultHeaderMap = new HashMap(); private Map defaultCookieMap = new HashMap(); @@ -19509,6 +27321,33 @@ public class ApiClient { return this; } + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + /** * Get HTTP client * @@ -19633,7 +27472,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setDateFormat(DateFormat dateFormat) { - this.json.setDateFormat(dateFormat); + JSON.setDateFormat(dateFormat); return this; } @@ -19644,7 +27483,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setSqlDateFormat(DateFormat dateFormat) { - this.json.setSqlDateFormat(dateFormat); + JSON.setSqlDateFormat(dateFormat); return this; } @@ -19655,7 +27494,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - this.json.setOffsetDateTimeFormat(dateFormat); + JSON.setOffsetDateTimeFormat(dateFormat); return this; } @@ -19666,7 +27505,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { - this.json.setLocalDateFormat(dateFormat); + JSON.setLocalDateFormat(dateFormat); return this; } @@ -19677,7 +27516,7 @@ public class ApiClient { * @return a {@link test.test.client.ApiClient} object */ public ApiClient setLenientOnJson(boolean lenientOnJson) { - this.json.setLenientOnJson(lenientOnJson); + JSON.setLenientOnJson(lenientOnJson); return this; } @@ -19770,6 +27609,18 @@ public class ApiClient { throw new RuntimeException(\\"No OAuth2 authentication configured!\\"); } + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException(\\"No AWS4 authentication configured!\\"); + } + /** * Set the User-Agent header's value (by adding to the default header map). * @@ -19938,7 +27789,7 @@ public class ApiClient { return \\"\\"; } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { //Serialize to json string and remove the \\" enclosing characters - String jsonStr = json.serialize(param); + String jsonStr = JSON.serialize(param); return jsonStr.substring(1, jsonStr.length() - 1); } else if (param instanceof Collection) { StringBuilder b = new StringBuilder(); @@ -19946,7 +27797,7 @@ public class ApiClient { if (b.length() > 0) { b.append(\\",\\"); } - b.append(String.valueOf(o)); + b.append(o); } return b.toString(); } else { @@ -20197,7 +28048,7 @@ public class ApiClient { contentType = \\"application/json\\"; } if (isJsonMime(contentType)) { - return json.deserialize(respBody, returnType); + return JSON.deserialize(respBody, returnType); } else if (returnType.equals(String.class)) { // Expecting string, return the raw response body. return (T) respBody; @@ -20231,11 +28082,13 @@ public class ApiClient { } else if (isJsonMime(contentType)) { String content; if (obj != null) { - content = json.serialize(obj); + content = JSON.serialize(obj); } else { content = null; } return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); } else { throw new ApiException(\\"Content type \\\\\\"\\" + contentType + \\"\\\\\\" is not supported\\"); } @@ -20526,7 +28379,18 @@ public class ApiClient { if (baseUrl != null) { url.append(baseUrl).append(path); } else { - url.append(basePath).append(path); + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + \\"Invalid index %d when selecting the host settings. Must be less than %d\\", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); } if (queryParams != null && !queryParams.isEmpty()) { @@ -20655,11 +28519,12 @@ public class ApiClient { for (Object item: list) { if (item instanceof File) { addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); } } } else { - Headers partHeaders = Headers.of(\\"Content-Disposition\\", \\"form-data; name=\\\\\\"\\" + param.getKey() + \\"\\\\\\"\\"); - mpBuilder.addPart(partHeaders, RequestBody.create(parameterToString(param.getValue()), null)); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); } } return mpBuilder.build(); @@ -20693,6 +28558,31 @@ public class ApiClient { mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); } + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + private void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse(\\"text/plain\\")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse(\\"application/json\\")); + } + + Headers partHeaders = Headers.of(\\"Content-Disposition\\", \\"form-data; name=\\\\\\"\\" + key + \\"\\\\\\"\\"); + mpBuilder.addPart(partHeaders, requestBody); + } + /** * Get network interceptor to add it to the httpClient to track download progress for * async requests. @@ -20760,7 +28650,7 @@ public class ApiClient { KeyStore caKeyStore = newEmptyKeyStore(password); int index = 0; for (Certificate certificate : certificates) { - String certificateAlias = \\"ca\\" + Integer.toString(index++); + String certificateAlias = \\"ca\\" + (index++); caKeyStore.setCertificateEntry(certificateAlias, certificate); } trustManagerFactory.init(caKeyStore); @@ -20793,7 +28683,7 @@ public class ApiClient { /** * Convert the HTTP request body to a string. * - * @param request The HTTP request object + * @param requestBody The HTTP request object * @return The string representation of the HTTP request body * @throws test.test.client.ApiException If fail to serialize the request body object into a string */ @@ -20914,7 +28804,7 @@ public class ApiException extends Exception { * @param responseBody the response body */ public ApiException(int code, Map> responseHeaders, String responseBody) { - this((String) null, (Throwable) null, code, responseHeaders, responseBody); + this(\\"Response Code: \\" + code + \\" Response Body: \\" + responseBody, (Throwable) null, code, responseHeaders, responseBody); } /** @@ -21831,7 +29721,7 @@ public class ServerConfiguration { throw new IllegalArgumentException(\\"The variable \\" + name + \\" in the server URL has invalid value \\" + value + \\".\\"); } } - url = url.replaceAll(\\"\\\\\\\\{\\" + name + \\"\\\\\\\\}\\", value); + url = url.replace(\\"{\\" + name + \\"}\\", value); } return url; } @@ -22054,7 +29944,6 @@ public class DefaultApi { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -22062,7 +29951,6 @@ public class DefaultApi { } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { @@ -22075,10 +29963,7 @@ public class DefaultApi { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call neitherValidateBeforeCall(final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = neitherCall(_callback); - return localVarCall; + return neitherCall(_callback); } @@ -23540,7 +31425,6 @@ public class Tag1Api { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -23548,7 +31432,6 @@ public class Tag1Api { } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { @@ -23561,10 +31444,7 @@ public class Tag1Api { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call tag1ValidateBeforeCall(final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = tag1Call(_callback); - return localVarCall; + return tag1Call(_callback); } @@ -23683,7 +31563,6 @@ public class Tag1Api { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -23691,7 +31570,6 @@ public class Tag1Api { } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { @@ -23704,10 +31582,7 @@ public class Tag1Api { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call tag1AgainValidateBeforeCall(final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = tag1AgainCall(_callback); - return localVarCall; + return tag1AgainCall(_callback); } @@ -23902,7 +31777,6 @@ public class Tag2Api { Map localVarFormParams = new HashMap(); final String[] localVarAccepts = { - }; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { @@ -23910,7 +31784,6 @@ public class Tag2Api { } final String[] localVarContentTypes = { - }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); if (localVarContentType != null) { @@ -23923,10 +31796,7 @@ public class Tag2Api { @SuppressWarnings(\\"rawtypes\\") private okhttp3.Call tag2ValidateBeforeCall(final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = tag2Call(_callback); - return localVarCall; + return tag2Call(_callback); } diff --git a/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-python-client-source-code.test.ts.snap b/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-python-client-source-code.test.ts.snap index 31f0e45e8..ca12322a2 100644 --- a/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-python-client-source-code.test.ts.snap +++ b/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-python-client-source-code.test.ts.snap @@ -197,7 +197,7 @@ test/test_models/test_test_request.py test/test_models/test_test_response.py tox.ini ", - ".openapi-generator/VERSION": "6.1.0", + ".openapi-generator/VERSION": "6.3.0", ".projen/deps.json": Object { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", "dependencies": Array [ @@ -373,13 +373,11 @@ This Python package is automatically generated by the [OpenAPI Generator](https: - API version: 1.0.0 - Package version: 1.0.0 -- Build package: org.openapitools.codegen.languages.PythonExperimentalClientCodegen +- Build package: org.openapitools.codegen.languages.PythonClientCodegen ## Requirements. -Python >=3.9 -v3.9 is needed so one can combine classmethod and property decorators to define -object schema properties as classes +Python >=3.7 ## Migration from other generators like python and python-legacy @@ -420,6 +418,16 @@ object schema properties as classes - A type hint is also generated for additionalProperties accessed using this method - So you will need to update you code to use some_instance['optionalProp'] to access optional property and additionalProperty values +8. The location of the api classes has changed + - Api classes are located in your_package.apis.tags.some_api + - This change was made to eliminate redundant code generation + - Legacy generators generated the same endpoint twice if it had > 1 tag on it + - This generator defines an endpoint in one class, then inherits that class to generate + apis by tags and by paths + - This change reduces code and allows quicker run time if you use the path apis + - path apis are at your_package.apis.paths.some_path + - Those apis will only load their needed models, which is less to load than all of the resources needed in a tag api + - So you will need to update your import paths to the api classes ### Why are Oapg and _oapg used in class and method names? Classes can have arbitrarily named properties set on them @@ -500,7 +508,7 @@ Please follow the [installation procedure](#installation--usage) and then run th import time import test from pprint import pprint -from test.apis import default_api +from test.apis.tags import default_api from test.model.api_error import ApiError from test.model.test_request import TestRequest from test.model.test_response import TestResponse @@ -633,10 +641,10 @@ skip_deserialization | bool | default is False | when True, headers and body wil ### body -#### SchemaForRequestBodyApplicationJson +# SchemaForRequestBodyApplicationJson Type | Description | Notes ------------- | ------------- | ------------- -[**TestRequest**](TestRequest.md) | | +[**TestRequest**](../../models/TestRequest.md) | | ### path_params @@ -646,49 +654,47 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- pathParam | PathParamSchema | | -#### PathParamSchema +# PathParamSchema -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +str, | str, | | ### Return Types, Responses Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -200 | ApiResponseFor200 | Successful response -400 | ApiResponseFor400 | Error response +200 | [ApiResponseFor200](#some_test_operation.ApiResponseFor200) | Successful response +400 | [ApiResponseFor400](#some_test_operation.ApiResponseFor400) | Error response -#### ApiResponseFor200 +#### some_test_operation.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | | headers | Unset | headers were not defined | -#### SchemaFor200ResponseBodyApplicationJson +# SchemaFor200ResponseBodyApplicationJson Type | Description | Notes ------------- | ------------- | ------------- -[**TestResponse**](TestResponse.md) | | +[**TestResponse**](../../models/TestResponse.md) | | -#### ApiResponseFor400 +#### some_test_operation.ApiResponseFor400 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | typing.Union[SchemaFor400ResponseBodyApplicationJson, ] | | headers | Unset | headers were not defined | -#### SchemaFor400ResponseBodyApplicationJson +# SchemaFor400ResponseBodyApplicationJson Type | Description | Notes ------------- | ------------- | ------------- -[**ApiError**](ApiError.md) | | - +[**ApiError**](../../models/ApiError.md) | | -[**TestResponse**](TestResponse.md) - ### Authorization No authorization required @@ -698,33 +704,74 @@ No authorization required ", "docs/models/ApiError.md": "# test.model.api_error.ApiError -#### Properties -Name | Type | Description | Notes +## Model Type Info +Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**errorMessage** | **str** | | -**any string name** | dict, frozendict, str, date, datetime, int, float, bool, Decimal, None, list, tuple, bytes | any string name can be used but the value must be the correct type | [optional] +dict, frozendict.frozendict, | frozendict.frozendict, | | + +### Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**errorMessage** | str, | str, | | +**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) ", "docs/models/TestRequest.md": "# test.model.test_request.TestRequest -#### Properties -Name | Type | Description | Notes +## Model Type Info +Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**myInput** | **int, float** | | [optional] -**any string name** | dict, frozendict, str, date, datetime, int, float, bool, Decimal, None, list, tuple, bytes | any string name can be used but the value must be the correct type | [optional] +dict, frozendict.frozendict, | frozendict.frozendict, | | + +### Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**myInput** | decimal.Decimal, int, float, | decimal.Decimal, | | [optional] +**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) ", "docs/models/TestResponse.md": "# test.model.test_response.TestResponse -#### Properties -Name | Type | Description | Notes +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +dict, frozendict.frozendict, | frozendict.frozendict, | | + +### Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**[messages](#messages)** | list, tuple, | tuple, | | +**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional] + +# messages + +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +list, tuple, | tuple, | | + +### Tuple Items +Class Name | Input Type | Accessed Type | Description | Notes +------------- | ------------- | ------------- | ------------- | ------------- +[items](#items) | dict, frozendict.frozendict, | frozendict.frozendict, | | + +# items + +## Model Type Info +Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**messages** | **[{str: (bool, date, datetime, dict, float, int, list, str, none_type)}]** | | -**any string name** | dict, frozendict, str, date, datetime, int, float, bool, Decimal, None, list, tuple, bytes | any string name can be used but the value must be the correct type | [optional] +dict, frozendict.frozendict, | frozendict.frozendict, | | + +### Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**id** | decimal.Decimal, int, | decimal.Decimal, | | +**message** | str, | str, | | [optional] +**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) @@ -732,7 +779,7 @@ Name | Type | Description | Notes "git_push.sh": "#!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl \\"minor update\\" \\"gitlab.com\\" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl \\"minor update\\" \\"gitlab.com\\" git_user_id=$1 git_repo_id=$2 @@ -791,11 +838,12 @@ git push origin master 2>&1 | grep -v 'To https' "requirements-dev.txt": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". projen==99.99.99 ", - "requirements.txt": "certifi >= 14.05.14 -frozendict >= 2.0.3 -python_dateutil >= 2.5.3 + "requirements.txt": "certifi >= 14.5.14 +frozendict ~= 2.3.4 +python-dateutil ~= 2.7.0 setuptools >= 21.0.0 -urllib3 >= 1.15.1 +typing_extensions ~= 4.3.0 +urllib3 ~= 1.26.7 ", "setup.cfg": "[flake8] max-line-length=99 @@ -823,10 +871,12 @@ VERSION = \\"1.0.0\\" # http://pypi.python.org/pypi/setuptools REQUIRES = [ - \\"urllib3 >= 1.15\\", - \\"certifi\\", - \\"python-dateutil\\", - \\"frozendict >= 2.0.3\\", + \\"certifi >= 14.5.14\\", + \\"frozendict ~= 2.3.4\\", + \\"python-dateutil ~= 2.7.0\\", + \\"setuptools >= 21.0.0\\", + \\"typing_extensions ~= 4.3.0\\", + \\"urllib3 ~= 1.26.7\\", ] setup( @@ -837,7 +887,7 @@ setup( author_email=\\"team@openapitools.org\\", url=\\"\\", keywords=[\\"OpenAPI\\", \\"OpenAPI-Generator\\", \\"Example API\\"], - python_requires=\\">=3.9\\", + python_requires=\\">=3.7\\", install_requires=REQUIRES, packages=find_packages(exclude=[\\"test\\", \\"tests\\"]), include_package_data=True, @@ -879,9 +929,10 @@ from multiprocessing.pool import ThreadPool import re import tempfile import typing +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict -from urllib.parse import quote +from urllib.parse import urlparse, quote from urllib3.fields import RequestField as RequestFieldBase import frozendict @@ -911,6 +962,8 @@ class RequestField(RequestFieldBase): class JSONEncoder(json.JSONEncoder): + compact_separators = (',', ':') + def default(self, obj): if isinstance(obj, str): return str(obj) @@ -1153,7 +1206,7 @@ class StyleFormSerializer(ParameterSerializerBase): prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None ) -> str: if prefix_separator_iterator is None: - prefix_separator_iterator = PrefixSeparatorIterator('?', '&') + prefix_separator_iterator = PrefixSeparatorIterator('', '&') return self._ref6570_expansion( variable_name=name, in_data=in_data, @@ -1182,8 +1235,25 @@ class StyleSimpleSerializer(ParameterSerializerBase): ) +class JSONDetector: + \\"\\"\\" + Works for: + application/json + application/json; charset=UTF-8 + application/json-patch+json + application/geo+json + \\"\\"\\" + __json_content_type_pattern = re.compile(\\"application/[^+]*[+]?(json);?.*\\") + + @classmethod + def _content_type_is_json(cls, content_type: str) -> bool: + if cls.__json_content_type_pattern.match(content_type): + return True + return False + + @dataclass -class ParameterBase: +class ParameterBase(JSONDetector): name: str in_type: ParameterInType required: bool @@ -1210,7 +1280,6 @@ class ParameterBase: } __disallowed_header_names = {'Accept', 'Content-Type', 'Authorization'} _json_encoder = JSONEncoder() - _json_content_type = 'application/json' @classmethod def __verify_style_to_in_type(cls, style: typing.Optional[ParameterStyle], in_type: ParameterInType): @@ -1257,8 +1326,11 @@ class ParameterBase: def _serialize_json( self, - in_data: typing.Union[None, int, float, str, bool, dict, list] + in_data: typing.Union[None, int, float, str, bool, dict, list], + eliminate_whitespace: bool = False ) -> str: + if eliminate_whitespace: + return json.dumps(in_data, separators=self._json_encoder.compact_separators) return json.dumps(in_data) @@ -1353,7 +1425,7 @@ class PathParameter(ParameterBase, StyleSimpleSerializer): for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: + if self._content_type_is_json(content_type): value = self._serialize_json(cast_in_data) return self._to_dict(self.name, value) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -1371,7 +1443,7 @@ class QueryParameter(ParameterBase, StyleFormSerializer): schema: typing.Optional[typing.Type[Schema]] = None, content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None ): - used_style = ParameterStyle.FORM if style is None and content is None and schema else style + used_style = ParameterStyle.FORM if style is None else style used_explode = self._get_default_explode(used_style) if explode is None else explode super().__init__( @@ -1434,8 +1506,6 @@ class QueryParameter(ParameterBase, StyleFormSerializer): return self._to_dict(self.name, value) def get_prefix_separator_iterator(self) -> typing.Optional[PrefixSeparatorIterator]: - if not self.schema: - return None if self.style is ParameterStyle.FORM: return PrefixSeparatorIterator('?', '&') elif self.style is ParameterStyle.SPACE_DELIMITED: @@ -1474,12 +1544,17 @@ class QueryParameter(ParameterBase, StyleFormSerializer): elif self.style is ParameterStyle.PIPE_DELIMITED: return self.__serialize_pipe_delimited(cast_in_data, prefix_separator_iterator) # self.content will be length one + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: - value = self._serialize_json(cast_in_data) - return self._to_dict(self.name, value) + if self._content_type_is_json(content_type): + value = self._serialize_json(cast_in_data, eliminate_whitespace=True) + return self._to_dict( + self.name, + next(prefix_separator_iterator) + self.name + '=' + quote(value) + ) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -1538,7 +1613,7 @@ class CookieParameter(ParameterBase, StyleFormSerializer): for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: + if self._content_type_is_json(content_type): value = self._serialize_json(cast_in_data) return self._to_dict(self.name, value) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -1567,7 +1642,7 @@ class HeaderParameter(ParameterBase, StyleSimpleSerializer): ) @staticmethod - def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict[str, str]: + def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict: data = tuple(t for t in in_data if t) headers = HTTPHeaderDict() if not data: @@ -1579,7 +1654,7 @@ class HeaderParameter(ParameterBase, StyleSimpleSerializer): self, in_data: typing.Union[ Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict.frozendict] - ) -> HTTPHeaderDict[str, str]: + ) -> HTTPHeaderDict: if self.schema: cast_in_data = self.schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) @@ -1595,7 +1670,7 @@ class HeaderParameter(ParameterBase, StyleSimpleSerializer): for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: + if self._content_type_is_json(content_type): value = self._serialize_json(cast_in_data) return self.__to_headers(((self.name, value),)) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -1634,14 +1709,14 @@ class MediaType: @dataclass class ApiResponse: response: urllib3.HTTPResponse - body: typing.Union[Unset, Schema] - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset def __init__( self, response: urllib3.HTTPResponse, - body: typing.Union[Unset, typing.Type[Schema]], - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset, + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset ): \\"\\"\\" pycharm needs this to prevent 'Unexpected argument' warnings @@ -1658,23 +1733,6 @@ class ApiResponseWithoutDeserialization(ApiResponse): headers: typing.Union[Unset, typing.List[HeaderParameter]] = unset -class JSONDetector: - \\"\\"\\" - Works for: - application/json - application/json; charset=UTF-8 - application/json-patch+json - application/geo+json - \\"\\"\\" - __json_content_type_pattern = re.compile(\\"application/[^+]*[+]?(json);?.*\\") - - @classmethod - def _content_type_is_json(cls, content_type: str) -> bool: - if cls.__json_content_type_pattern.match(content_type): - return True - return False - - class OpenApiResponse(JSONDetector): __filename_content_disposition_pattern = re.compile('filename=\\"(.+?)\\"') @@ -1695,6 +1753,19 @@ class OpenApiResponse(JSONDetector): # python must be >= 3.9 so we can pass in bytes into json.loads return json.loads(response.data) + @staticmethod + def __file_name_from_response_url(response_url: typing.Optional[str]) -> typing.Optional[str]: + if response_url is None: + return None + url_path = urlparse(response_url).path + if url_path: + path_basename = os.path.basename(url_path) + if path_basename: + _filename, ext = os.path.splitext(path_basename) + if ext: + return path_basename + return None + @classmethod def __file_name_from_content_disposition(cls, content_disposition: typing.Optional[str]) -> typing.Optional[str]: if content_disposition is None: @@ -1714,13 +1785,16 @@ class OpenApiResponse(JSONDetector): a file will be written and returned \\"\\"\\" if response.supports_chunked_reads(): - file_name = self.__file_name_from_content_disposition(response.headers.get('content-disposition')) + file_name = ( + self.__file_name_from_content_disposition(response.headers.get('content-disposition')) + or self.__file_name_from_response_url(response.geturl()) + ) if file_name is None: _fd, path = tempfile.mkstemp() else: path = os.path.join(tempfile.gettempdir(), file_name) - # TODO get file_name from the filename at the end of the url if it exists + with open(path, 'wb') as new_file: chunk_size = 1024 while True: @@ -1762,8 +1836,8 @@ class OpenApiResponse(JSONDetector): if self.content is not None: if content_type not in self.content: raise ApiValueError( - f'Invalid content_type={content_type} returned for response with ' - 'status_code={str(response.status)}' + f\\"Invalid content_type returned. Content_type='{content_type}' was returned \\" + f\\"when only {str(set(self.content))} are defined for status_code={str(response.status)}\\" ) body_schema = self.content[content_type].schema if body_schema is None: @@ -1833,7 +1907,7 @@ class ApiClient: self.pool_threads = pool_threads self.rest_client = rest.RESTClientObject(configuration) - self.default_headers = {} + self.default_headers = HTTPHeaderDict() if header_name is not None: self.default_headers[header_name] = header_value self.cookie = cookie @@ -1890,15 +1964,18 @@ class ApiClient: ) -> urllib3.HTTPResponse: # header parameters - headers = headers or {} - headers.update(self.default_headers) + used_headers = HTTPHeaderDict(self.default_headers) if self.cookie: headers['Cookie'] = self.cookie # auth setting - self.update_params_for_auth(headers, + self.update_params_for_auth(used_headers, auth_settings, resource_path, method, body) + # must happen after cookie setting and auth setting in case user is overriding those + if headers: + used_headers.update(headers) + # request url if host is None: url = self.configuration.host + resource_path @@ -1910,7 +1987,7 @@ class ApiClient: response = self.request( method, url, - headers=headers, + headers=used_headers, fields=fields, body=body, stream=stream, @@ -2103,7 +2180,7 @@ class Api: self.api_client = api_client @staticmethod - def _verify_typed_dict_inputs_oapg(cls: typing.Type[typing.TypedDict], data: typing.Dict[str, typing.Any]): + def _verify_typed_dict_inputs_oapg(cls: typing.Type[typing_extensions.TypedDict], data: typing.Dict[str, typing.Any]): \\"\\"\\" Ensures that: - required keys are present @@ -2175,9 +2252,9 @@ class Api: return host -class SerializedRequestBody(typing.TypedDict, total=False): +class SerializedRequestBody(typing_extensions.TypedDict, total=False): body: typing.Union[str, bytes] - fields: typing.Tuple[typing.Union[RequestField, tuple[str, str]], ...] + fields: typing.Tuple[typing.Union[RequestField, typing.Tuple[str, str]], ...] class RequestBody(StyleFormSerializer, JSONDetector): @@ -2221,24 +2298,24 @@ class RequestBody(StyleFormSerializer, JSONDetector): def __multipart_json_item(self, key: str, value: Schema) -> RequestField: json_value = self.__json_encoder.default(value) - return RequestField(name=key, data=json.dumps(json_value), headers={'Content-Type': 'application/json'}) + request_field = RequestField(name=key, data=json.dumps(json_value)) + request_field.make_multipart(content_type='application/json') + return request_field def __multipart_form_item(self, key: str, value: Schema) -> RequestField: if isinstance(value, str): - return RequestField(name=key, data=str(value), headers={'Content-Type': 'text/plain'}) + request_field = RequestField(name=key, data=str(value)) + request_field.make_multipart(content_type='text/plain') elif isinstance(value, bytes): - return RequestField(name=key, data=value, headers={'Content-Type': 'application/octet-stream'}) + request_field = RequestField(name=key, data=value) + request_field.make_multipart(content_type='application/octet-stream') elif isinstance(value, FileIO): - request_field = RequestField( - name=key, - data=value.read(), - filename=os.path.basename(value.name), - headers={'Content-Type': 'application/octet-stream'} - ) + # TODO use content.encoding to limit allowed content types if they are present + request_field = RequestField.from_tuples(key, (os.path.basename(value.name), value.read())) value.close() - return request_field else: - return self.__multipart_json_item(key=key, value=value) + request_field = self.__multipart_json_item(key=key, value=value) + return request_field def __serialize_multipart_form_data( self, in_data: Schema @@ -2294,7 +2371,7 @@ class RequestBody(StyleFormSerializer, JSONDetector): raise ValueError( f'Unable to serialize {in_data} to application/x-www-form-urlencoded because it is not a dict of data') cast_in_data = self.__json_encoder.default(in_data) - value = self._serialize_form(cast_in_data, name='', explode=True, percent_encode=False) + value = self._serialize_form(cast_in_data, name='', explode=True, percent_encode=True) return dict(body=value) def serialize( @@ -2328,17 +2405,16 @@ class RequestBody(StyleFormSerializer, JSONDetector): return self.__serialize_application_x_www_form_data(cast_in_data) elif content_type == 'application/octet-stream': return self.__serialize_application_octet_stream(cast_in_data) - raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type)) -", + raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type))", "test/apis/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames # if you need the ability to import all endpoints then import them from # tags, paths, or path_to_api, or tag_to_api", - "test/apis/path_to_api.py": "import typing + "test/apis/path_to_api.py": "import typing_extensions from test.paths import PathValues from test.apis.paths.operation_path_param import OperationPathParam -PathToApi = typing.TypedDict( +PathToApi = typing_extensions.TypedDict( 'PathToApi', { PathValues.OPERATION_PATH_PARAM: OperationPathParam, @@ -2363,12 +2439,12 @@ class OperationPathParam( ): pass ", - "test/apis/tag_to_api.py": "import typing + "test/apis/tag_to_api.py": "import typing_extensions from test.apis.tags import TagValues from test.apis.tags.default_api import DefaultApi -TagToApi = typing.TypedDict( +TagToApi = typing_extensions.TypedDict( 'TagToApi', { TagValues.DEFAULT: DefaultApi, @@ -2718,14 +2794,16 @@ class Configuration(object): _default = None - def __init__(self, host=None, - api_key=None, api_key_prefix=None, - username=None, password=None, - discard_unknown_keys=False, - disabled_client_side_validations=\\"\\", - server_index=None, server_variables=None, - server_operation_index=None, server_operation_variables=None, - ): + def __init__( + self, + host=None, + discard_unknown_keys=False, + disabled_client_side_validations=\\"\\", + server_index=None, + server_variables=None, + server_operation_index=None, + server_operation_variables=None, + ): \\"\\"\\"Constructor \\"\\"\\" self._base_path = \\"http://localhost\\" if host is None else host @@ -2743,26 +2821,6 @@ class Configuration(object): \\"\\"\\"Temp file folder for downloading files \\"\\"\\" # Authentication Settings - self.api_key = {} - if api_key: - self.api_key = api_key - \\"\\"\\"dict to store API key(s) - \\"\\"\\" - self.api_key_prefix = {} - if api_key_prefix: - self.api_key_prefix = api_key_prefix - \\"\\"\\"dict to store API prefix (e.g. Bearer) - \\"\\"\\" - self.refresh_api_key_hook = None - \\"\\"\\"function hook to refresh API key if expired - \\"\\"\\" - self.username = username - \\"\\"\\"Username for HTTP basic authentication - \\"\\"\\" - self.password = password - \\"\\"\\"Password for HTTP basic authentication - \\"\\"\\" - self.discard_unknown_keys = discard_unknown_keys self.disabled_client_side_validations = disabled_client_side_validations self.logger = {} \\"\\"\\"Logging Settings @@ -3096,6 +3154,10 @@ class Configuration(object): The version of the OpenAPI document: 1.0.0 Generated by: https://openapi-generator.tech \\"\\"\\" +import dataclasses +import typing + +from urllib3._collections import HTTPHeaderDict class OpenApiException(Exception): @@ -3185,19 +3247,26 @@ class ApiKeyError(OpenApiException, KeyError): super(ApiKeyError, self).__init__(full_msg) -class ApiException(OpenApiException): +T = typing.TypeVar(\\"T\\") - def __init__(self, status=None, reason=None, api_response: 'test.api_client.ApiResponse' = None): - if api_response: - self.status = api_response.response.status - self.reason = api_response.response.reason - self.body = api_response.response.data - self.headers = api_response.response.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + +@dataclasses.dataclass +class ApiException(OpenApiException, typing.Generic[T]): + status: int + reason: str + api_response: typing.Optional[T] = None + + @property + def body(self) -> typing.Union[str, bytes, None]: + if not self.api_response: + return None + return self.api_response.response.data + + @property + def headers(self) -> typing.Optional[HTTPHeaderDict]: + if not self.api_response: + return None + return self.api_response.response.getheaders() def __str__(self): \\"\\"\\"Custom error messages for exception\\"\\"\\" @@ -3246,6 +3315,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -3267,6 +3337,7 @@ class ApiError( required = { \\"errorMessage\\", } + class properties: errorMessage = schemas.StrSchema __annotations__ = { @@ -3276,36 +3347,36 @@ class ApiError( errorMessage: MetaOapg.properties.errorMessage @typing.overload - def __getitem__(self, name: typing.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... + def __getitem__(self, name: typing_extensions.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"errorMessage\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"errorMessage\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"errorMessage\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"errorMessage\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], + *_args: typing.Union[dict, frozendict.frozendict, ], errorMessage: typing.Union[MetaOapg.properties.errorMessage, str, ], _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'ApiError': return super().__new__( cls, - *args, + *_args, errorMessage=errorMessage, _configuration=_configuration, **kwargs, @@ -3328,6 +3399,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -3349,6 +3421,7 @@ class ApiError( required = { \\"errorMessage\\", } + class properties: errorMessage = schemas.StrSchema __annotations__ = { @@ -3358,36 +3431,36 @@ class ApiError( errorMessage: MetaOapg.properties.errorMessage @typing.overload - def __getitem__(self, name: typing.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... + def __getitem__(self, name: typing_extensions.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"errorMessage\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"errorMessage\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"errorMessage\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"errorMessage\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], + *_args: typing.Union[dict, frozendict.frozendict, ], errorMessage: typing.Union[MetaOapg.properties.errorMessage, str, ], _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'ApiError': return super().__new__( cls, - *args, + *_args, errorMessage=errorMessage, _configuration=_configuration, **kwargs, @@ -3410,6 +3483,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -3428,6 +3502,7 @@ class TestRequest( class MetaOapg: + class properties: myInput = schemas.NumberSchema __annotations__ = { @@ -3435,36 +3510,36 @@ class TestRequest( } @typing.overload - def __getitem__(self, name: typing.Literal[\\"myInput\\"]) -> MetaOapg.properties.myInput: ... + def __getitem__(self, name: typing_extensions.Literal[\\"myInput\\"]) -> MetaOapg.properties.myInput: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"myInput\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"myInput\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"myInput\\"]) -> typing.Union[MetaOapg.properties.myInput, schemas.Unset]: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"myInput\\"]) -> typing.Union[MetaOapg.properties.myInput, schemas.Unset]: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"myInput\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"myInput\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], + *_args: typing.Union[dict, frozendict.frozendict, ], myInput: typing.Union[MetaOapg.properties.myInput, decimal.Decimal, int, float, schemas.Unset] = schemas.unset, _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'TestRequest': return super().__new__( cls, - *args, + *_args, myInput=myInput, _configuration=_configuration, **kwargs, @@ -3487,6 +3562,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -3505,6 +3581,7 @@ class TestRequest( class MetaOapg: + class properties: myInput = schemas.NumberSchema __annotations__ = { @@ -3512,36 +3589,36 @@ class TestRequest( } @typing.overload - def __getitem__(self, name: typing.Literal[\\"myInput\\"]) -> MetaOapg.properties.myInput: ... + def __getitem__(self, name: typing_extensions.Literal[\\"myInput\\"]) -> MetaOapg.properties.myInput: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"myInput\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"myInput\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"myInput\\"]) -> typing.Union[MetaOapg.properties.myInput, schemas.Unset]: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"myInput\\"]) -> typing.Union[MetaOapg.properties.myInput, schemas.Unset]: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"myInput\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"myInput\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], + *_args: typing.Union[dict, frozendict.frozendict, ], myInput: typing.Union[MetaOapg.properties.myInput, decimal.Decimal, int, float, schemas.Unset] = schemas.unset, _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'TestRequest': return super().__new__( cls, - *args, + *_args, myInput=myInput, _configuration=_configuration, **kwargs, @@ -3564,6 +3641,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -3585,6 +3663,7 @@ class TestResponse( required = { \\"messages\\", } + class properties: @@ -3605,6 +3684,7 @@ class TestResponse( required = { \\"id\\", } + class properties: message = schemas.StrSchema id = schemas.IntSchema @@ -3616,43 +3696,43 @@ class TestResponse( id: MetaOapg.properties.id @typing.overload - def __getitem__(self, name: typing.Literal[\\"message\\"]) -> MetaOapg.properties.message: ... + def __getitem__(self, name: typing_extensions.Literal[\\"message\\"]) -> MetaOapg.properties.message: ... @typing.overload - def __getitem__(self, name: typing.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... + def __getitem__(self, name: typing_extensions.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"message\\", \\"id\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"message\\", \\"id\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"message\\"]) -> typing.Union[MetaOapg.properties.message, schemas.Unset]: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"message\\"]) -> typing.Union[MetaOapg.properties.message, schemas.Unset]: ... @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"message\\", \\"id\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"message\\", \\"id\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], - id: typing.Union[MetaOapg.properties.id, int, ], + *_args: typing.Union[dict, frozendict.frozendict, ], + id: typing.Union[MetaOapg.properties.id, decimal.Decimal, int, ], message: typing.Union[MetaOapg.properties.message, str, schemas.Unset] = schemas.unset, _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'items': return super().__new__( cls, - *args, + *_args, id=id, message=message, _configuration=_configuration, @@ -3661,12 +3741,12 @@ class TestResponse( def __new__( cls, - arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]]], + _arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]]], _configuration: typing.Optional[schemas.Configuration] = None, ) -> 'messages': return super().__new__( cls, - arg, + _arg, _configuration=_configuration, ) @@ -3679,36 +3759,36 @@ class TestResponse( messages: MetaOapg.properties.messages @typing.overload - def __getitem__(self, name: typing.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... + def __getitem__(self, name: typing_extensions.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"messages\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"messages\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"messages\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"messages\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], - messages: typing.Union[MetaOapg.properties.messages, tuple, ], + *_args: typing.Union[dict, frozendict.frozendict, ], + messages: typing.Union[MetaOapg.properties.messages, list, tuple, ], _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'TestResponse': return super().__new__( cls, - *args, + *_args, messages=messages, _configuration=_configuration, **kwargs, @@ -3731,6 +3811,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -3752,6 +3833,7 @@ class TestResponse( required = { \\"messages\\", } + class properties: @@ -3772,6 +3854,7 @@ class TestResponse( required = { \\"id\\", } + class properties: message = schemas.StrSchema id = schemas.IntSchema @@ -3783,43 +3866,43 @@ class TestResponse( id: MetaOapg.properties.id @typing.overload - def __getitem__(self, name: typing.Literal[\\"message\\"]) -> MetaOapg.properties.message: ... + def __getitem__(self, name: typing_extensions.Literal[\\"message\\"]) -> MetaOapg.properties.message: ... @typing.overload - def __getitem__(self, name: typing.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... + def __getitem__(self, name: typing_extensions.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"message\\", \\"id\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"message\\", \\"id\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"message\\"]) -> typing.Union[MetaOapg.properties.message, schemas.Unset]: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"message\\"]) -> typing.Union[MetaOapg.properties.message, schemas.Unset]: ... @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"message\\", \\"id\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"message\\", \\"id\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], - id: typing.Union[MetaOapg.properties.id, int, ], + *_args: typing.Union[dict, frozendict.frozendict, ], + id: typing.Union[MetaOapg.properties.id, decimal.Decimal, int, ], message: typing.Union[MetaOapg.properties.message, str, schemas.Unset] = schemas.unset, _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'items': return super().__new__( cls, - *args, + *_args, id=id, message=message, _configuration=_configuration, @@ -3828,12 +3911,12 @@ class TestResponse( def __new__( cls, - arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]]], + _arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]]], _configuration: typing.Optional[schemas.Configuration] = None, ) -> 'messages': return super().__new__( cls, - arg, + _arg, _configuration=_configuration, ) @@ -3846,36 +3929,36 @@ class TestResponse( messages: MetaOapg.properties.messages @typing.overload - def __getitem__(self, name: typing.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... + def __getitem__(self, name: typing_extensions.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"messages\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"messages\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"messages\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"messages\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], - messages: typing.Union[MetaOapg.properties.messages, tuple, ], + *_args: typing.Union[dict, frozendict.frozendict, ], + messages: typing.Union[MetaOapg.properties.messages, list, tuple, ], _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'TestResponse': return super().__new__( cls, - *args, + *_args, messages=messages, _configuration=_configuration, **kwargs, @@ -3889,7 +3972,7 @@ class TestResponse( # if you have many models here with many references from one model to another this may # raise a RecursionError # to avoid this, import only the models that you directly need like: -# from from test.model.pet import Pet +# from test.model.pet import Pet # or import this package, but before doing it, use: # import sys # sys.setrecursionlimit(n) @@ -3924,6 +4007,7 @@ path = PathValues.OPERATION_PATH_PARAM", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -3934,6 +4018,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -3946,15 +4031,15 @@ from test.model.test_request import TestRequest from . import path -# path params +# Path params PathParamSchema = schemas.StrSchema -RequestRequiredPathParams = typing.TypedDict( +RequestRequiredPathParams = typing_extensions.TypedDict( 'RequestRequiredPathParams', { 'pathParam': typing.Union[PathParamSchema, str, ], } ) -RequestOptionalPathParams = typing.TypedDict( +RequestOptionalPathParams = typing_extensions.TypedDict( 'RequestOptionalPathParams', { }, @@ -4031,20 +4116,72 @@ _all_accept_content_types = ( class BaseApi(api_client.Api): + @typing.overload + def _some_test_operation_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _some_test_operation_oapg( - self: api_client.Api, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def _some_test_operation_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _some_test_operation_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _some_test_operation_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -4103,7 +4240,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -4111,19 +4252,72 @@ class BaseApi(api_client.Api): class SomeTestOperation(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def some_test_operation( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def some_test_operation( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def some_test_operation( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def some_test_operation( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def some_test_operation( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._some_test_operation_oapg( body=body, path_params=path_params, @@ -4138,19 +4332,72 @@ class SomeTestOperation(BaseApi): class ApiForpost(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def post( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._some_test_operation_oapg( body=body, path_params=path_params, @@ -4172,6 +4419,7 @@ class ApiForpost(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -4182,6 +4430,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -4192,38 +4441,159 @@ from test.model.test_response import TestResponse from test.model.api_error import ApiError from test.model.test_request import TestRequest -# path params +# Path params PathParamSchema = schemas.StrSchema -# body param -SchemaForRequestBodyApplicationJson = TestRequest -SchemaFor200ResponseBodyApplicationJson = TestResponse -SchemaFor400ResponseBodyApplicationJson = ApiError -_all_accept_content_types = ( - 'application/json', +RequestRequiredPathParams = typing_extensions.TypedDict( + 'RequestRequiredPathParams', + { + 'pathParam': typing.Union[PathParamSchema, str, ], + } +) +RequestOptionalPathParams = typing_extensions.TypedDict( + 'RequestOptionalPathParams', + { + }, + total=False ) -class BaseApi(api_client.Api): +class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams): + pass - def _some_test_operation_oapg( - self: api_client.Api, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], - path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', - accept_content_types: typing.Tuple[str] = _all_accept_content_types, - stream: bool = False, - timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, - ) -> typing.Union[ - ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: - \\"\\"\\" - :param skip_deserialization: If true then api_response.response will be set but - api_response.body and api_response.headers will not be deserialized into schema - class instances - \\"\\"\\" - self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params) + +request_path_path_param = api_client.PathParameter( + name=\\"pathParam\\", + style=api_client.ParameterStyle.SIMPLE, + schema=PathParamSchema, + required=True, +) +# body param +SchemaForRequestBodyApplicationJson = TestRequest + + +request_body_test_request = api_client.RequestBody( + content={ + 'application/json': api_client.MediaType( + schema=SchemaForRequestBodyApplicationJson), + }, + required=True, +) +SchemaFor200ResponseBodyApplicationJson = TestResponse + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[ + SchemaFor200ResponseBodyApplicationJson, + ] + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, + content={ + 'application/json': api_client.MediaType( + schema=SchemaFor200ResponseBodyApplicationJson), + }, +) +SchemaFor400ResponseBodyApplicationJson = ApiError + + +@dataclass +class ApiResponseFor400(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[ + SchemaFor400ResponseBodyApplicationJson, + ] + headers: schemas.Unset = schemas.unset + + +_response_for_400 = api_client.OpenApiResponse( + response_cls=ApiResponseFor400, + content={ + 'application/json': api_client.MediaType( + schema=SchemaFor400ResponseBodyApplicationJson), + }, +) +_all_accept_content_types = ( + 'application/json', +) + + +class BaseApi(api_client.Api): + @typing.overload + def _some_test_operation_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _some_test_operation_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def _some_test_operation_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _some_test_operation_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _some_test_operation_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + \\"\\"\\" + :param skip_deserialization: If true then api_response.response will be set but + api_response.body and api_response.headers will not be deserialized into schema + class instances + \\"\\"\\" + self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params) used_path = path.value _path_params = {} @@ -4276,7 +4646,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -4284,19 +4658,72 @@ class BaseApi(api_client.Api): class SomeTestOperation(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def some_test_operation( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def some_test_operation( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def some_test_operation( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def some_test_operation( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def some_test_operation( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._some_test_operation_oapg( body=body, path_params=path_params, @@ -4311,19 +4738,72 @@ class SomeTestOperation(BaseApi): class ApiForpost(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def post( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._some_test_operation_oapg( body=body, path_params=path_params, @@ -4484,6 +4964,7 @@ class RESTClientObject(object): elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( method, url, + body=body, fields=fields, encode_multipart=False, preload_content=not stream, @@ -4607,6 +5088,7 @@ import functools import decimal import io import re +import types import typing import uuid @@ -4641,17 +5123,17 @@ class FileIO(io.FileIO): Note: this class is not immutable \\"\\"\\" - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader]): - if isinstance(arg, (io.FileIO, io.BufferedReader)): - if arg.closed: + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader]): + if isinstance(_arg, (io.FileIO, io.BufferedReader)): + if _arg.closed: raise ApiValueError('Invalid file state; file is closed and must be open') - arg.close() - inst = super(FileIO, cls).__new__(cls, arg.name) - super(FileIO, inst).__init__(arg.name) + _arg.close() + inst = super(FileIO, cls).__new__(cls, _arg.name) + super(FileIO, inst).__init__(_arg.name) return inst - raise ApiValueError('FileIO must be passed arg which contains the open file') + raise ApiValueError('FileIO must be passed _arg which contains the open file') - def __init__(self, arg: typing.Union[io.FileIO, io.BufferedReader]): + def __init__(self, _arg: typing.Union[io.FileIO, io.BufferedReader]): pass @@ -4739,14 +5221,27 @@ class ValidationMetadata(frozendict.frozendict): return self.get('validated_path_to_schemas') +def add_deeper_validated_schemas(validation_metadata: ValidationMetadata, path_to_schemas: dict): + # this is called if validation_ran_earlier and current and deeper locations need to be added + current_path_to_item = validation_metadata.path_to_item + other_path_to_schemas = {} + for path_to_item, schemas in validation_metadata.validated_path_to_schemas.items(): + if len(path_to_item) < len(current_path_to_item): + continue + path_begins_with_current_path = path_to_item[:len(current_path_to_item)] == current_path_to_item + if path_begins_with_current_path: + other_path_to_schemas[path_to_item] = schemas + update(path_to_schemas, other_path_to_schemas) + + class Singleton: \\"\\"\\" Enums and singletons are the same - The same instance is returned for a given key of (cls, arg) + The same instance is returned for a given key of (cls, _arg) \\"\\"\\" _instances = {} - def __new__(cls, arg: typing.Any, **kwargs): + def __new__(cls, _arg: typing.Any, **kwargs): \\"\\"\\" cls base classes: BoolClass, NoneClass, str, decimal.Decimal The 3rd key is used in the tuple below for a corner case where an enum contains integer 1 @@ -4754,15 +5249,15 @@ class Singleton: Decimal('1.0') == Decimal('1') But if we omitted the 3rd value in the key, then Decimal('1.0') would be stored as Decimal('1') and json serializing that instance would be '1' rather than the expected '1.0' - Adding the 3rd value, the str of arg ensures that 1.0 -> Decimal('1.0') which is serialized as 1.0 + Adding the 3rd value, the str of _arg ensures that 1.0 -> Decimal('1.0') which is serialized as 1.0 \\"\\"\\" - key = (cls, arg, str(arg)) + key = (cls, _arg, str(_arg)) if key not in cls._instances: - if isinstance(arg, (none_type, bool, BoolClass, NoneClass)): + if isinstance(_arg, (none_type, bool, BoolClass, NoneClass)): inst = super().__new__(cls) cls._instances[key] = inst else: - cls._instances[key] = super().__new__(cls, arg) + cls._instances[key] = super().__new__(cls, _arg) return cls._instances[key] def __repr__(self): @@ -4775,9 +5270,17 @@ class Singleton: return f'<{self.__class__.__name__}: {super().__repr__()}>' +class classproperty: + + def __init__(self, fget): + self.fget = fget + + def __get__(self, owner_self, owner_cls): + return self.fget(owner_cls) + + class NoneClass(Singleton): - @classmethod - @property + @classproperty def NONE(cls): return cls(None) @@ -4786,17 +5289,15 @@ class NoneClass(Singleton): class BoolClass(Singleton): - @classmethod - @property + @classproperty def TRUE(cls): return cls(True) - @classmethod - @property + @classproperty def FALSE(cls): return cls(False) - @functools.cache + @functools.lru_cache() def __bool__(self) -> bool: for key, instance in self._instances.items(): if self is instance: @@ -4835,8 +5336,70 @@ class Schema: the base class of all swagger/openapi schemas/models \\"\\"\\" __inheritable_primitive_types_set = {decimal.Decimal, str, tuple, frozendict.frozendict, FileIO, bytes, BoolClass, NoneClass} + _types: typing.Set[typing.Type] MetaOapg = MetaOapgTyped + @staticmethod + def __get_valid_classes_phrase(input_classes): + \\"\\"\\"Returns a string phrase describing what types are allowed\\"\\"\\" + all_classes = list(input_classes) + all_classes = sorted(all_classes, key=lambda cls: cls.__name__) + all_class_names = [cls.__name__ for cls in all_classes] + if len(all_class_names) == 1: + return \\"is {0}\\".format(all_class_names[0]) + return \\"is one of [{0}]\\".format(\\", \\".join(all_class_names)) + + @staticmethod + def _get_class_oapg(item_cls: typing.Union[types.FunctionType, staticmethod, typing.Type['Schema']]) -> typing.Type['Schema']: + if isinstance(item_cls, types.FunctionType): + # referenced schema + return item_cls() + elif isinstance(item_cls, staticmethod): + # referenced schema + return item_cls.__func__() + return item_cls + + @classmethod + def __type_error_message( + cls, var_value=None, var_name=None, valid_classes=None, key_type=None + ): + \\"\\"\\" + Keyword Args: + var_value (any): the variable which has the type_error + var_name (str): the name of the variable which has the typ error + valid_classes (tuple): the accepted classes for current_item's + value + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a tuple + \\"\\"\\" + key_or_value = \\"value\\" + if key_type: + key_or_value = \\"key\\" + valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) + msg = \\"Invalid type. Required {1} type {2} and \\" \\"passed type was {3}\\".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) + return msg + + @classmethod + def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): + error_msg = cls.__type_error_message( + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type, + ) + return ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type, + ) + @classmethod def _validate_oapg( cls, @@ -4845,21 +5408,8 @@ class Schema: ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: \\"\\"\\" Schema _validate_oapg - Runs all schema validation logic and - returns a dynamic class of different bases depending upon the input - This makes it so: - - the returned instance is always a subclass of our defining schema - - this allows us to check type based on whether an instance is a subclass of a schema - - the returned instance is a serializable type (except for None, True, and False) which are enums - - Use cases: - 1. inheritable type: string/decimal.Decimal/frozendict.frozendict/tuple - 2. singletons: bool/None -> uses the base classes BoolClass/NoneClass - - Required Steps: - 1. verify type of input is valid vs the allowed _types - 2. check validations that are applicable for this type of input - 3. if enums exist, check that the value exists in the enum + All keyword validation except for type checking was done in calling stack frames + If those validations passed, the validated classes are collected in path_to_schemas Returns: path_to_schemas: a map of path to schemas @@ -4869,6 +5419,14 @@ class Schema: ApiTypeError: when the input type is not in the list of allowed spec types \\"\\"\\" base_class = type(arg) + if base_class not in cls._types: + raise cls.__get_type_error( + arg, + validation_metadata.path_to_item, + cls._types, + key_type=False, + ) + path_to_schemas = {validation_metadata.path_to_item: set()} path_to_schemas[validation_metadata.path_to_item].add(cls) path_to_schemas[validation_metadata.path_to_item].add(base_class) @@ -4913,16 +5471,16 @@ class Schema: _validate_oapg returns a key value pair where the key is the path to the item, and the value will be the required manufactured class made out of the matching schemas - 2. value is an instance of the the correct schema type + 2. value is an instance of the correct schema type the value is NOT validated by _validate_oapg, _validate_oapg only checks that the instance is of the correct schema type for this value, _validate_oapg does NOT return an entry for it in _path_to_schemas and in list/dict _get_items_oapg,_get_properties_oapg the value will be directly assigned because value is of the correct type, and validation was run earlier when the instance was created \\"\\"\\" _path_to_schemas = {} - if validation_metadata.validated_path_to_schemas: - update(_path_to_schemas, validation_metadata.validated_path_to_schemas) - if not validation_metadata.validation_ran_earlier(cls): + if validation_metadata.validation_ran_earlier(cls): + add_deeper_validated_schemas(validation_metadata, _path_to_schemas) + else: other_path_to_schemas = cls._validate_oapg(arg, validation_metadata=validation_metadata) update(_path_to_schemas, other_path_to_schemas) # loop through it make a new class for each entry @@ -4939,7 +5497,7 @@ class Schema: \\"\\"\\" cls._process_schema_classes_oapg(schema_classes) enum_schema = any( - hasattr(this_cls, '_enum_value_to_name') for this_cls in schema_classes) + issubclass(this_cls, EnumBase) for this_cls in schema_classes) inheritable_primitive_type = schema_classes.intersection(cls.__inheritable_primitive_types_set) chosen_schema_classes = schema_classes - inheritable_primitive_type suffix = tuple(inheritable_primitive_type) @@ -5027,12 +5585,12 @@ class Schema: def __remove_unsets(kwargs): return {key: val for key, val in kwargs.items() if val is not unset} - def __new__(cls, *args: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): + def __new__(cls, *_args: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): \\"\\"\\" Schema __new__ Args: - args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): the value + _args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): the value kwargs (str, int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): dict values _configuration: contains the Configuration that enables json schema validation keywords like minItems, minLength etc @@ -5041,14 +5599,14 @@ class Schema: are instance properties if they are named normally :( \\"\\"\\" __kwargs = cls.__remove_unsets(kwargs) - if not args and not __kwargs: + if not _args and not __kwargs: raise TypeError( 'No input given. args or kwargs must be given.' ) - if not __kwargs and args and not isinstance(args[0], dict): - __arg = args[0] + if not __kwargs and _args and not isinstance(_args[0], dict): + __arg = _args[0] else: - __arg = cls.__get_input_dict(*args, **__kwargs) + __arg = cls.__get_input_dict(*_args, **__kwargs) __from_server = False __validated_path_to_schemas = {} __arg = cast_to_allowed_types( @@ -5065,7 +5623,7 @@ class Schema: def __init__( self, - *args: typing.Union[ + *_args: typing.Union[ dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[ @@ -5083,17 +5641,33 @@ class Schema: \\"\\"\\" import itertools data_types = ('None', 'FrozenDict', 'Tuple', 'Str', 'Decimal', 'Bool') -[v for v in itertools.combinations(data_types, 2)] +type_to_cls = { + 'None': 'NoneClass', + 'FrozenDict': 'frozendict.frozendict', + 'Tuple': 'tuple', + 'Str': 'str', + 'Decimal': 'decimal.Decimal', + 'Bool': 'BoolClass' +} +cls_tuples = [v for v in itertools.combinations(data_types, 5)] +typed_classes = [f\\"class {''.join(cls_tuple)}Mixin({', '.join(type_to_cls[typ] for typ in cls_tuple)}):\\\\n pass\\" for cls_tuple in cls_tuples] +for cls in typed_classes: + print(cls) +object_classes = [f\\"{''.join(cls_tuple)}Mixin = object\\" for cls_tuple in cls_tuples] +for cls in object_classes: + print(cls) \\"\\"\\" if typing.TYPE_CHECKING: - # qty 1 mixin + # qty 1 NoneMixin = NoneClass FrozenDictMixin = frozendict.frozendict TupleMixin = tuple StrMixin = str DecimalMixin = decimal.Decimal BoolMixin = BoolClass - # qty 2 mixin + BytesMixin = bytes + FileMixin = FileIO + # qty 2 class BinaryMixin(bytes, FileIO): pass class NoneFrozenDictMixin(NoneClass, frozendict.frozendict): @@ -5126,42 +5700,246 @@ if typing.TYPE_CHECKING: pass class DecimalBoolMixin(decimal.Decimal, BoolClass): pass - # qty 6 - class NoneFrozenDictTupleStrDecimalBoolMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass): + # qty 3 + class NoneFrozenDictTupleMixin(NoneClass, frozendict.frozendict, tuple): pass -else: - # qty 1 mixin - NoneMixin = object - FrozenDictMixin = object - TupleMixin = object - StrMixin = object - DecimalMixin = object - BoolMixin = object - # qty 2 mixin - BinaryMixin = object - NoneFrozenDictMixin = object - NoneTupleMixin = object - NoneStrMixin = object - NoneDecimalMixin = object - NoneBoolMixin = object - FrozenDictTupleMixin = object - FrozenDictStrMixin = object - FrozenDictDecimalMixin = object - FrozenDictBoolMixin = object - TupleStrMixin = object - TupleDecimalMixin = object - TupleBoolMixin = object - StrDecimalMixin = object - StrBoolMixin = object - DecimalBoolMixin = object - NoneFrozenDictTupleStrDecimalBoolMixin = object - - -class ValidatorBase: - @staticmethod - def _is_json_validation_enabled_oapg(schema_keyword, configuration=None): - \\"\\"\\"Returns true if JSON schema validation is enabled for the specified - validation keyword. This can be used to skip JSON schema structural validation + class NoneFrozenDictStrMixin(NoneClass, frozendict.frozendict, str): + pass + class NoneFrozenDictDecimalMixin(NoneClass, frozendict.frozendict, decimal.Decimal): + pass + class NoneFrozenDictBoolMixin(NoneClass, frozendict.frozendict, BoolClass): + pass + class NoneTupleStrMixin(NoneClass, tuple, str): + pass + class NoneTupleDecimalMixin(NoneClass, tuple, decimal.Decimal): + pass + class NoneTupleBoolMixin(NoneClass, tuple, BoolClass): + pass + class NoneStrDecimalMixin(NoneClass, str, decimal.Decimal): + pass + class NoneStrBoolMixin(NoneClass, str, BoolClass): + pass + class NoneDecimalBoolMixin(NoneClass, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrMixin(frozendict.frozendict, tuple, str): + pass + class FrozenDictTupleDecimalMixin(frozendict.frozendict, tuple, decimal.Decimal): + pass + class FrozenDictTupleBoolMixin(frozendict.frozendict, tuple, BoolClass): + pass + class FrozenDictStrDecimalMixin(frozendict.frozendict, str, decimal.Decimal): + pass + class FrozenDictStrBoolMixin(frozendict.frozendict, str, BoolClass): + pass + class FrozenDictDecimalBoolMixin(frozendict.frozendict, decimal.Decimal, BoolClass): + pass + class TupleStrDecimalMixin(tuple, str, decimal.Decimal): + pass + class TupleStrBoolMixin(tuple, str, BoolClass): + pass + class TupleDecimalBoolMixin(tuple, decimal.Decimal, BoolClass): + pass + class StrDecimalBoolMixin(str, decimal.Decimal, BoolClass): + pass + # qty 4 + class NoneFrozenDictTupleStrMixin(NoneClass, frozendict.frozendict, tuple, str): + pass + class NoneFrozenDictTupleDecimalMixin(NoneClass, frozendict.frozendict, tuple, decimal.Decimal): + pass + class NoneFrozenDictTupleBoolMixin(NoneClass, frozendict.frozendict, tuple, BoolClass): + pass + class NoneFrozenDictStrDecimalMixin(NoneClass, frozendict.frozendict, str, decimal.Decimal): + pass + class NoneFrozenDictStrBoolMixin(NoneClass, frozendict.frozendict, str, BoolClass): + pass + class NoneFrozenDictDecimalBoolMixin(NoneClass, frozendict.frozendict, decimal.Decimal, BoolClass): + pass + class NoneTupleStrDecimalMixin(NoneClass, tuple, str, decimal.Decimal): + pass + class NoneTupleStrBoolMixin(NoneClass, tuple, str, BoolClass): + pass + class NoneTupleDecimalBoolMixin(NoneClass, tuple, decimal.Decimal, BoolClass): + pass + class NoneStrDecimalBoolMixin(NoneClass, str, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrDecimalMixin(frozendict.frozendict, tuple, str, decimal.Decimal): + pass + class FrozenDictTupleStrBoolMixin(frozendict.frozendict, tuple, str, BoolClass): + pass + class FrozenDictTupleDecimalBoolMixin(frozendict.frozendict, tuple, decimal.Decimal, BoolClass): + pass + class FrozenDictStrDecimalBoolMixin(frozendict.frozendict, str, decimal.Decimal, BoolClass): + pass + class TupleStrDecimalBoolMixin(tuple, str, decimal.Decimal, BoolClass): + pass + # qty 5 + class NoneFrozenDictTupleStrDecimalMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal): + pass + class NoneFrozenDictTupleStrBoolMixin(NoneClass, frozendict.frozendict, tuple, str, BoolClass): + pass + class NoneFrozenDictTupleDecimalBoolMixin(NoneClass, frozendict.frozendict, tuple, decimal.Decimal, BoolClass): + pass + class NoneFrozenDictStrDecimalBoolMixin(NoneClass, frozendict.frozendict, str, decimal.Decimal, BoolClass): + pass + class NoneTupleStrDecimalBoolMixin(NoneClass, tuple, str, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrDecimalBoolMixin(frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass): + pass + # qty 6 + class NoneFrozenDictTupleStrDecimalBoolMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass): + pass + # qty 8 + class NoneFrozenDictTupleStrDecimalBoolFileBytesMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass, FileIO, bytes): + pass +else: + # qty 1 + class NoneMixin: + _types = {NoneClass} + class FrozenDictMixin: + _types = {frozendict.frozendict} + class TupleMixin: + _types = {tuple} + class StrMixin: + _types = {str} + class DecimalMixin: + _types = {decimal.Decimal} + class BoolMixin: + _types = {BoolClass} + class BytesMixin: + _types = {bytes} + class FileMixin: + _types = {FileIO} + # qty 2 + class BinaryMixin: + _types = {bytes, FileIO} + class NoneFrozenDictMixin: + _types = {NoneClass, frozendict.frozendict} + class NoneTupleMixin: + _types = {NoneClass, tuple} + class NoneStrMixin: + _types = {NoneClass, str} + class NoneDecimalMixin: + _types = {NoneClass, decimal.Decimal} + class NoneBoolMixin: + _types = {NoneClass, BoolClass} + class FrozenDictTupleMixin: + _types = {frozendict.frozendict, tuple} + class FrozenDictStrMixin: + _types = {frozendict.frozendict, str} + class FrozenDictDecimalMixin: + _types = {frozendict.frozendict, decimal.Decimal} + class FrozenDictBoolMixin: + _types = {frozendict.frozendict, BoolClass} + class TupleStrMixin: + _types = {tuple, str} + class TupleDecimalMixin: + _types = {tuple, decimal.Decimal} + class TupleBoolMixin: + _types = {tuple, BoolClass} + class StrDecimalMixin: + _types = {str, decimal.Decimal} + class StrBoolMixin: + _types = {str, BoolClass} + class DecimalBoolMixin: + _types = {decimal.Decimal, BoolClass} + # qty 3 + class NoneFrozenDictTupleMixin: + _types = {NoneClass, frozendict.frozendict, tuple} + class NoneFrozenDictStrMixin: + _types = {NoneClass, frozendict.frozendict, str} + class NoneFrozenDictDecimalMixin: + _types = {NoneClass, frozendict.frozendict, decimal.Decimal} + class NoneFrozenDictBoolMixin: + _types = {NoneClass, frozendict.frozendict, BoolClass} + class NoneTupleStrMixin: + _types = {NoneClass, tuple, str} + class NoneTupleDecimalMixin: + _types = {NoneClass, tuple, decimal.Decimal} + class NoneTupleBoolMixin: + _types = {NoneClass, tuple, BoolClass} + class NoneStrDecimalMixin: + _types = {NoneClass, str, decimal.Decimal} + class NoneStrBoolMixin: + _types = {NoneClass, str, BoolClass} + class NoneDecimalBoolMixin: + _types = {NoneClass, decimal.Decimal, BoolClass} + class FrozenDictTupleStrMixin: + _types = {frozendict.frozendict, tuple, str} + class FrozenDictTupleDecimalMixin: + _types = {frozendict.frozendict, tuple, decimal.Decimal} + class FrozenDictTupleBoolMixin: + _types = {frozendict.frozendict, tuple, BoolClass} + class FrozenDictStrDecimalMixin: + _types = {frozendict.frozendict, str, decimal.Decimal} + class FrozenDictStrBoolMixin: + _types = {frozendict.frozendict, str, BoolClass} + class FrozenDictDecimalBoolMixin: + _types = {frozendict.frozendict, decimal.Decimal, BoolClass} + class TupleStrDecimalMixin: + _types = {tuple, str, decimal.Decimal} + class TupleStrBoolMixin: + _types = {tuple, str, BoolClass} + class TupleDecimalBoolMixin: + _types = {tuple, decimal.Decimal, BoolClass} + class StrDecimalBoolMixin: + _types = {str, decimal.Decimal, BoolClass} + # qty 4 + class NoneFrozenDictTupleStrMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str} + class NoneFrozenDictTupleDecimalMixin: + _types = {NoneClass, frozendict.frozendict, tuple, decimal.Decimal} + class NoneFrozenDictTupleBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, BoolClass} + class NoneFrozenDictStrDecimalMixin: + _types = {NoneClass, frozendict.frozendict, str, decimal.Decimal} + class NoneFrozenDictStrBoolMixin: + _types = {NoneClass, frozendict.frozendict, str, BoolClass} + class NoneFrozenDictDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, decimal.Decimal, BoolClass} + class NoneTupleStrDecimalMixin: + _types = {NoneClass, tuple, str, decimal.Decimal} + class NoneTupleStrBoolMixin: + _types = {NoneClass, tuple, str, BoolClass} + class NoneTupleDecimalBoolMixin: + _types = {NoneClass, tuple, decimal.Decimal, BoolClass} + class NoneStrDecimalBoolMixin: + _types = {NoneClass, str, decimal.Decimal, BoolClass} + class FrozenDictTupleStrDecimalMixin: + _types = {frozendict.frozendict, tuple, str, decimal.Decimal} + class FrozenDictTupleStrBoolMixin: + _types = {frozendict.frozendict, tuple, str, BoolClass} + class FrozenDictTupleDecimalBoolMixin: + _types = {frozendict.frozendict, tuple, decimal.Decimal, BoolClass} + class FrozenDictStrDecimalBoolMixin: + _types = {frozendict.frozendict, str, decimal.Decimal, BoolClass} + class TupleStrDecimalBoolMixin: + _types = {tuple, str, decimal.Decimal, BoolClass} + # qty 5 + class NoneFrozenDictTupleStrDecimalMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal} + class NoneFrozenDictTupleStrBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, BoolClass} + class NoneFrozenDictTupleDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, decimal.Decimal, BoolClass} + class NoneFrozenDictStrDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, str, decimal.Decimal, BoolClass} + class NoneTupleStrDecimalBoolMixin: + _types = {NoneClass, tuple, str, decimal.Decimal, BoolClass} + class FrozenDictTupleStrDecimalBoolMixin: + _types = {frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass} + # qty 6 + class NoneFrozenDictTupleStrDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass} + # qty 8 + class NoneFrozenDictTupleStrDecimalBoolFileBytesMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass, FileIO, bytes} + + +class ValidatorBase: + @staticmethod + def _is_json_validation_enabled_oapg(schema_keyword, configuration=None): + \\"\\"\\"Returns true if JSON schema validation is enabled for the specified + validation keyword. This can be used to skip JSON schema structural validation as requested in the configuration. Note: the suffix _oapg stands for openapi python (experimental) generator and it has been added to prevent collisions with other methods and properties @@ -5176,7 +5954,7 @@ class ValidatorBase: schema_keyword not in configuration._disabled_client_side_validations) @staticmethod - def _raise_validation_errror_message_oapg(value, constraint_msg, constraint_value, path_to_item, additional_txt=\\"\\"): + def _raise_validation_error_message_oapg(value, constraint_msg, constraint_value, path_to_item, additional_txt=\\"\\"): raise ApiValueError( \\"Invalid value \`{value}\`, {constraint_msg} \`{constraint_value}\`{additional_txt} at {path_to_item}\\".format( value=value, @@ -5188,147 +5966,22 @@ class ValidatorBase: ) -class Validator(typing.Protocol): +class EnumBase: @classmethod def _validate_oapg( cls, arg, validation_metadata: ValidationMetadata, ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - pass - - -def SchemaTypeCheckerClsFactory(union_type_cls: typing.Union[typing.Any]) -> Validator: - if typing.get_origin(union_type_cls) is typing.Union: - union_classes = typing.get_args(union_type_cls) - else: - # note: when a union of a single class is passed in, the union disappears - union_classes = tuple([union_type_cls]) - \\"\\"\\" - I want the type hint... union_type_cls - and to use it as a base class but when I do, I get - TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases - \\"\\"\\" - class SchemaTypeChecker: - @staticmethod - def __get_valid_classes_phrase(input_classes): - \\"\\"\\"Returns a string phrase describing what types are allowed\\"\\"\\" - all_classes = list(input_classes) - all_classes = sorted(all_classes, key=lambda cls: cls.__name__) - all_class_names = [cls.__name__ for cls in all_classes] - if len(all_class_names) == 1: - return \\"is {0}\\".format(all_class_names[0]) - return \\"is one of [{0}]\\".format(\\", \\".join(all_class_names)) - - @classmethod - def __type_error_message( - cls, var_value=None, var_name=None, valid_classes=None, key_type=None - ): - \\"\\"\\" - Keyword Args: - var_value (any): the variable which has the type_error - var_name (str): the name of the variable which has the typ error - valid_classes (tuple): the accepted classes for current_item's - value - key_type (bool): False if our value is a value in a dict - True if it is a key in a dict - False if our item is an item in a tuple - \\"\\"\\" - key_or_value = \\"value\\" - if key_type: - key_or_value = \\"key\\" - valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) - msg = \\"Invalid type. Required {1} type {2} and \\" \\"passed type was {3}\\".format( - var_name, - key_or_value, - valid_classes_phrase, - type(var_value).__name__, - ) - return msg - - @classmethod - def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): - error_msg = cls.__type_error_message( - var_name=path_to_item[-1], - var_value=var_value, - valid_classes=valid_classes, - key_type=key_type, - ) - return ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=valid_classes, - key_type=key_type, - ) - - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - \\"\\"\\" - SchemaTypeChecker _validate_oapg - Validates arg's type - \\"\\"\\" - arg_type = type(arg) - if arg_type in union_classes: - return super()._validate_oapg(arg, validation_metadata=validation_metadata) - raise cls.__get_type_error( - arg, - validation_metadata.path_to_item, - union_classes, - key_type=False, - ) - - return SchemaTypeChecker - - -class EnumMakerBase: - pass - - -class EnumMakerInterface(Validator): - @classmethod - @property - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - - -def SchemaEnumMakerClsFactory(enum_value_to_name: typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]) -> EnumMakerInterface: - class SchemaEnumMaker(EnumMakerBase): - @classmethod - @property - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - try: - super_enum_value_to_name = super()._enum_value_to_name - except AttributeError: - return enum_value_to_name - intersection = dict(enum_value_to_name.items() & super_enum_value_to_name.items()) - return intersection - - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - \\"\\"\\" - SchemaEnumMaker _validate_oapg - Validates that arg is in the enum's allowed values - \\"\\"\\" - try: - cls._enum_value_to_name[arg] - except KeyError: - raise ApiValueError(\\"Invalid value {} passed in to {}, {}\\".format(arg, cls, cls._enum_value_to_name)) - return super()._validate_oapg(arg, validation_metadata=validation_metadata) - - return SchemaEnumMaker + \\"\\"\\" + EnumBase _validate_oapg + Validates that arg is in the enum's allowed values + \\"\\"\\" + try: + cls.MetaOapg.enum_value_to_name[arg] + except KeyError: + raise ApiValueError(\\"Invalid value {} passed in to {}, allowed_values={}\\".format(arg, cls, cls.MetaOapg.enum_value_to_name.keys())) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class BoolBase: @@ -5396,7 +6049,7 @@ class StrBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('maxLength', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'max_length') and len(arg) > cls.MetaOapg.max_length): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"length must be less than or equal to\\", constraint_value=cls.MetaOapg.max_length, @@ -5406,7 +6059,7 @@ class StrBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('minLength', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'min_length') and len(arg) < cls.MetaOapg.min_length): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"length must be greater than or equal to\\", constraint_value=cls.MetaOapg.min_length, @@ -5421,14 +6074,14 @@ class StrBase(ValidatorBase): if flags != 0: # Don't print the regex flags if the flags are not # specified in the OAS document. - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must match regular expression\\", constraint_value=regex_dict['pattern'], path_to_item=validation_metadata.path_to_item, additional_txt=\\" with flags=\`{}\`\\".format(flags) ) - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must match regular expression\\", constraint_value=regex_dict['pattern'], @@ -5450,9 +6103,9 @@ class StrBase(ValidatorBase): return super()._validate_oapg(arg, validation_metadata=validation_metadata) -class UUIDBase(StrBase): +class UUIDBase: @property - @functools.cache + @functools.lru_cache() def as_uuid_oapg(self) -> uuid.UUID: return uuid.UUID(self) @@ -5516,9 +6169,9 @@ class CustomIsoparser(isoparser): DEFAULT_ISOPARSER = CustomIsoparser() -class DateBase(StrBase): +class DateBase: @property - @functools.cache + @functools.lru_cache() def as_date_oapg(self) -> date: return DEFAULT_ISOPARSER.parse_isodate(self) @@ -5549,7 +6202,7 @@ class DateBase(StrBase): class DateTimeBase: @property - @functools.cache + @functools.lru_cache() def as_datetime_oapg(self) -> datetime: return DEFAULT_ISOPARSER.parse_isodatetime(self) @@ -5578,7 +6231,7 @@ class DateTimeBase: return super()._validate_oapg(arg, validation_metadata=validation_metadata) -class DecimalBase(StrBase): +class DecimalBase: \\"\\"\\" A class for storing decimals that are sent over the wire as strings These schemas must remain based on StrBase rather than NumberBase @@ -5586,7 +6239,7 @@ class DecimalBase(StrBase): \\"\\"\\" @property - @functools.cache + @functools.lru_cache() def as_decimal_oapg(self) -> decimal.Decimal: return decimal.Decimal(self) @@ -5644,7 +6297,7 @@ class NumberBase(ValidatorBase): return self._as_float except AttributeError: if self.as_tuple().exponent >= 0: - raise ApiValueError(f'{self} is not an float') + raise ApiValueError(f'{self} is not a float') self._as_float = float(self) return self._as_float @@ -5661,7 +6314,7 @@ class NumberBase(ValidatorBase): multiple_of_value = cls.MetaOapg.multiple_of if (not (float(arg) / multiple_of_value).is_integer()): # Note 'multipleOf' will be as good as the floating point arithmetic. - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"value must be a multiple of\\", constraint_value=multiple_of_value, @@ -5682,7 +6335,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('exclusiveMaximum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'exclusive_maximum') and arg >= cls.MetaOapg.exclusive_maximum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value less than\\", constraint_value=cls.MetaOapg.exclusive_maximum, @@ -5692,7 +6345,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('maximum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'inclusive_maximum') and arg > cls.MetaOapg.inclusive_maximum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value less than or equal to\\", constraint_value=cls.MetaOapg.inclusive_maximum, @@ -5702,7 +6355,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('exclusiveMinimum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'exclusive_minimum') and arg <= cls.MetaOapg.exclusive_minimum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value greater than\\", constraint_value=cls.MetaOapg.exclusive_maximum, @@ -5712,7 +6365,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('minimum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'inclusive_minimum') and arg < cls.MetaOapg.inclusive_minimum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value greater than or equal to\\", constraint_value=cls.MetaOapg.inclusive_minimum, @@ -5755,6 +6408,7 @@ class ListBase(ValidatorBase): # if we have definitions for an items schema, use it # otherwise accept anything item_cls = getattr(cls.MetaOapg, 'items', UnsetAnyTypeSchema) + item_cls = cls._get_class_oapg(item_cls) path_to_schemas = {} for i, value in enumerate(list_items): item_validation_metadata = ValidationMetadata( @@ -5764,6 +6418,7 @@ class ListBase(ValidatorBase): validated_path_to_schemas=validation_metadata.validated_path_to_schemas ) if item_validation_metadata.validation_ran_earlier(item_cls): + add_deeper_validated_schemas(item_validation_metadata, path_to_schemas) continue other_path_to_schemas = item_cls._validate_oapg( value, validation_metadata=item_validation_metadata) @@ -5779,7 +6434,7 @@ class ListBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('maxItems', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'max_items') and len(arg) > cls.MetaOapg.max_items): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of items must be less than or equal to\\", constraint_value=cls.MetaOapg.max_items, @@ -5789,7 +6444,7 @@ class ListBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('minItems', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'min_items') and len(arg) < cls.MetaOapg.min_items): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of items must be greater than or equal to\\", constraint_value=cls.MetaOapg.min_items, @@ -5800,7 +6455,7 @@ class ListBase(ValidatorBase): hasattr(cls.MetaOapg, 'unique_items') and cls.MetaOapg.unique_items and arg): unique_items = set(arg) if len(arg) > len(unique_items): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"duplicate items were found, and the tuple must not contain duplicates because\\", constraint_value='unique_items==True', @@ -5888,7 +6543,7 @@ class Discriminable: \\"\\"\\" if not hasattr(cls.MetaOapg, 'discriminator'): return None - disc = cls.MetaOapg.discriminator + disc = cls.MetaOapg.discriminator() if disc_property_name not in disc: return None discriminated_cls = disc[disc_property_name].get(disc_payload_value) @@ -5903,21 +6558,24 @@ class Discriminable: ): return None # TODO stop traveling if a cycle is hit - for allof_cls in getattr(cls.MetaOapg, 'all_of', []): - discriminated_cls = allof_cls.get_discriminated_class_oapg( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - for oneof_cls in getattr(cls.MetaOapg, 'one_of', []): - discriminated_cls = oneof_cls.get_discriminated_class_oapg( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - for anyof_cls in getattr(cls.MetaOapg, 'any_of', []): - discriminated_cls = anyof_cls.get_discriminated_class_oapg( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls + if hasattr(cls.MetaOapg, 'all_of'): + for allof_cls in cls.MetaOapg.all_of(): + discriminated_cls = allof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + if hasattr(cls.MetaOapg, 'one_of'): + for oneof_cls in cls.MetaOapg.one_of(): + discriminated_cls = oneof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + if hasattr(cls.MetaOapg, 'any_of'): + for anyof_cls in cls.MetaOapg.any_of(): + discriminated_cls = anyof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls return None @@ -6016,9 +6674,7 @@ class DictBase(Discriminable, ValidatorBase): raise ApiTypeError('Unable to find schema for value={} in class={} at path_to_item={}'.format( value, cls, validation_metadata.path_to_item+(property_name,) )) - if isinstance(schema, classmethod): - # referenced schema, call classmethod property - schema = schema.__func__.fget(properties) + schema = cls._get_class_oapg(schema) arg_validation_metadata = ValidationMetadata( from_server=validation_metadata.from_server, configuration=validation_metadata.configuration, @@ -6026,6 +6682,7 @@ class DictBase(Discriminable, ValidatorBase): validated_path_to_schemas=validation_metadata.validated_path_to_schemas ) if arg_validation_metadata.validation_ran_earlier(schema): + add_deeper_validated_schemas(arg_validation_metadata, path_to_schemas) continue other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata) update(path_to_schemas, other_path_to_schemas) @@ -6042,7 +6699,7 @@ class DictBase(Discriminable, ValidatorBase): if (cls._is_json_validation_enabled_oapg('maxProperties', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'max_properties') and len(arg) > cls.MetaOapg.max_properties): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of properties must be less than or equal to\\", constraint_value=cls.MetaOapg.max_properties, @@ -6052,7 +6709,7 @@ class DictBase(Discriminable, ValidatorBase): if (cls._is_json_validation_enabled_oapg('minProperties', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'min_properties') and len(arg) < cls.MetaOapg.min_properties): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of properties must be greater than or equal to\\", constraint_value=cls.MetaOapg.min_properties, @@ -6089,7 +6746,7 @@ class DictBase(Discriminable, ValidatorBase): other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata) update(_path_to_schemas, other_path_to_schemas) try: - discriminator = cls.MetaOapg.discriminator + discriminator = cls.MetaOapg.discriminator() except AttributeError: return _path_to_schemas # discriminator exists @@ -6114,6 +6771,7 @@ class DictBase(Discriminable, ValidatorBase): validated_path_to_schemas=validation_metadata.validated_path_to_schemas ) if updated_vm.validation_ran_earlier(discriminated_cls): + add_deeper_validated_schemas(updated_vm, _path_to_schemas) return _path_to_schemas other_path_to_schemas = discriminated_cls._validate_oapg(arg, validation_metadata=updated_vm) update(_path_to_schemas, other_path_to_schemas) @@ -6212,18 +6870,11 @@ def cast_to_allowed_types( if isinstance(arg, Schema): # store the already run validations schema_classes = set() - source_schema_was_unset = len(arg.__class__.__bases__) == 2 and UnsetAnyTypeSchema in arg.__class__.__bases__ - if not source_schema_was_unset: - \\"\\"\\" - Do not include UnsetAnyTypeSchema and its base class because - it did not exist in the original spec schema definition - It was added to ensure that all instances are of type Schema and the allowed base types - \\"\\"\\" - for cls in arg.__class__.__bases__: - if cls is Singleton: - # Skip Singleton - continue - schema_classes.add(cls) + for cls in arg.__class__.__bases__: + if cls is Singleton: + # Skip Singleton + continue + schema_classes.add(cls) validated_path_to_schemas[path_to_item] = schema_classes type_error = ApiTypeError(f\\"Invalid type. Required value type is str and passed type was {type(arg)} at {path_to_item}\\") @@ -6274,8 +6925,9 @@ class ComposedBase(Discriminable): @classmethod def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): path_to_schemas = defaultdict(set) - for allof_cls in cls.MetaOapg.all_of: + for allof_cls in cls.MetaOapg.all_of(): if validation_metadata.validation_ran_earlier(allof_cls): + add_deeper_validated_schemas(validation_metadata, path_to_schemas) continue other_path_to_schemas = allof_cls._validate_oapg(arg, validation_metadata=validation_metadata) update(path_to_schemas, other_path_to_schemas) @@ -6290,12 +6942,13 @@ class ComposedBase(Discriminable): ): oneof_classes = [] path_to_schemas = defaultdict(set) - for oneof_cls in cls.MetaOapg.one_of: + for oneof_cls in cls.MetaOapg.one_of(): if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: oneof_classes.append(oneof_cls) continue if validation_metadata.validation_ran_earlier(oneof_cls): oneof_classes.append(oneof_cls) + add_deeper_validated_schemas(validation_metadata, path_to_schemas) continue try: path_to_schemas = oneof_cls._validate_oapg(arg, validation_metadata=validation_metadata) @@ -6314,6 +6967,7 @@ class ComposedBase(Discriminable): \\"Invalid inputs given to generate an instance of {}. Multiple \\" \\"oneOf schemas {} matched the inputs, but a max of one is allowed.\\".format(cls, oneof_classes) ) + # exactly one class matches return path_to_schemas @classmethod @@ -6325,9 +6979,10 @@ class ComposedBase(Discriminable): ): anyof_classes = [] path_to_schemas = defaultdict(set) - for anyof_cls in cls.MetaOapg.any_of: + for anyof_cls in cls.MetaOapg.any_of(): if validation_metadata.validation_ran_earlier(anyof_cls): anyof_classes.append(anyof_cls) + add_deeper_validated_schemas(validation_metadata, path_to_schemas) continue try: @@ -6378,7 +7033,9 @@ class ComposedBase(Discriminable): ) # process composed schema - discriminator = getattr(cls, 'discriminator', None) + discriminator = None + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'discriminator'): + discriminator = cls.MetaOapg.discriminator() discriminated_cls = None if discriminator and arg and isinstance(arg, frozendict.frozendict): disc_property_name = list(discriminator.keys())[0] @@ -6415,8 +7072,9 @@ class ComposedBase(Discriminable): ) update(path_to_schemas, other_path_to_schemas) not_cls = None - if hasattr(cls, 'MetaOapg'): - not_cls = getattr(cls.MetaOapg, 'not_schema', None) + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'not_schema'): + not_cls = cls.MetaOapg.not_schema + not_cls = cls._get_class_oapg(not_cls) if not_cls: other_path_to_schemas = None not_exception = ApiValueError( @@ -6438,13 +7096,13 @@ class ComposedBase(Discriminable): if discriminated_cls is not None and not updated_vm.validation_ran_earlier(discriminated_cls): # TODO use an exception from this package here + add_deeper_validated_schemas(updated_vm, path_to_schemas) assert discriminated_cls in path_to_schemas[updated_vm.path_to_item] return path_to_schemas # DictBase, ListBase, NumberBase, StrBase, BoolBase, NoneBase class ComposedSchema( - SchemaTypeCheckerClsFactory(typing.Union[NoneClass, str, decimal.Decimal, BoolClass, tuple, frozendict.frozendict]), ComposedBase, DictBase, ListBase, @@ -6465,7 +7123,6 @@ class ComposedSchema( class ListSchema( - SchemaTypeCheckerClsFactory(typing.Union[tuple]), ListBase, Schema, TupleMixin @@ -6475,12 +7132,11 @@ class ListSchema( def from_openapi_data_oapg(cls, arg: typing.List[typing.Any], _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[typing.List[typing.Any], typing.Tuple[typing.Any]], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[typing.List[typing.Any], typing.Tuple[typing.Any]], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class NoneSchema( - SchemaTypeCheckerClsFactory(typing.Union[NoneClass]), NoneBase, Schema, NoneMixin @@ -6490,12 +7146,11 @@ class NoneSchema( def from_openapi_data_oapg(cls, arg: None, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: None, **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: None, **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class NumberSchema( - SchemaTypeCheckerClsFactory(typing.Union[decimal.Decimal]), NumberBase, Schema, DecimalMixin @@ -6506,14 +7161,14 @@ class NumberSchema( \\"\\"\\" @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[int, float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + def from_openapi_data_oapg(cls, arg: typing.Union[int, float], _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[decimal.Decimal, int, float], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[decimal.Decimal, int, float], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) -class IntBase(NumberBase): +class IntBase: @property def as_int_oapg(self) -> int: try: @@ -6552,15 +7207,33 @@ class IntSchema(IntBase, NumberSchema): def from_openapi_data_oapg(cls, arg: int, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[decimal.Decimal, int], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[decimal.Decimal, int], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class Int32Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-2147483648) - inclusive_maximum = decimal.Decimal(2147483647) + __inclusive_minimum = decimal.Decimal(-2147483648) + __inclusive_maximum = decimal.Decimal(2147483647) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal) and arg.as_tuple().exponent == 0: + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type int32 at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Int32Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Int32Schema( @@ -6571,10 +7244,28 @@ class Int32Schema( class Int64Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-9223372036854775808) - inclusive_maximum = decimal.Decimal(9223372036854775807) + __inclusive_minimum = decimal.Decimal(-9223372036854775808) + __inclusive_maximum = decimal.Decimal(9223372036854775807) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal) and arg.as_tuple().exponent == 0: + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type int64 at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Int64Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Int64Schema( @@ -6585,10 +7276,28 @@ class Int64Schema( class Float32Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-3.4028234663852886e+38) - inclusive_maximum = decimal.Decimal(3.4028234663852886e+38) + __inclusive_minimum = decimal.Decimal(-3.4028234663852886e+38) + __inclusive_maximum = decimal.Decimal(3.4028234663852886e+38) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type float at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Float32Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Float32Schema( @@ -6597,17 +7306,33 @@ class Float32Schema( ): @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): - # todo check format + def from_openapi_data_oapg(cls, arg: float, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) class Float64Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-1.7976931348623157E+308) - inclusive_maximum = decimal.Decimal(1.7976931348623157E+308) + __inclusive_minimum = decimal.Decimal(-1.7976931348623157E+308) + __inclusive_maximum = decimal.Decimal(1.7976931348623157E+308) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type double at {}\\".format(arg, validation_metadata.path_to_item) + ) + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Float64Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Float64Schema( Float64Base, @@ -6615,13 +7340,12 @@ class Float64Schema( ): @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + def from_openapi_data_oapg(cls, arg: float, _configuration: typing.Optional[Configuration] = None): # todo check format return super().from_openapi_data_oapg(arg, _configuration=_configuration) class StrSchema( - SchemaTypeCheckerClsFactory(typing.Union[str]), StrBase, Schema, StrMixin @@ -6634,34 +7358,34 @@ class StrSchema( \\"\\"\\" @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[str], _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': + def from_openapi_data_oapg(cls, arg: str, _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class UUIDSchema(UUIDBase, StrSchema): - def __new__(cls, arg: typing.Union[str, uuid.UUID], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, uuid.UUID], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class DateSchema(DateBase, StrSchema): - def __new__(cls, arg: typing.Union[str, date], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, date], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class DateTimeSchema(DateTimeBase, StrSchema): - def __new__(cls, arg: typing.Union[str, datetime], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, datetime], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class DecimalSchema(DecimalBase, StrSchema): - def __new__(cls, arg: typing.Union[str], **kwargs: Configuration): + def __new__(cls, _arg: str, **kwargs: Configuration): \\"\\"\\" Note: Decimals may not be passed in because cast_to_allowed_types is only invoked once for payloads which can be simple (str) or complex (dicts or lists with nested values) @@ -6670,23 +7394,23 @@ class DecimalSchema(DecimalBase, StrSchema): if one was using it for a StrSchema (where it should be cast to str) or one is using it for NumberSchema where it should stay as Decimal. \\"\\"\\" - return super().__new__(cls, arg, **kwargs) + return super().__new__(cls, _arg, **kwargs) class BytesSchema( - SchemaTypeCheckerClsFactory(typing.Union[bytes]), Schema, + BytesMixin ): \\"\\"\\" this class will subclass bytes and is immutable \\"\\"\\" - def __new__(cls, arg: typing.Union[bytes], **kwargs: Configuration): - return super(Schema, cls).__new__(cls, arg) + def __new__(cls, _arg: bytes, **kwargs: Configuration): + return super(Schema, cls).__new__(cls, _arg) class FileSchema( - SchemaTypeCheckerClsFactory(typing.Union[FileIO]), Schema, + FileMixin ): \\"\\"\\" This class is NOT immutable @@ -6705,8 +7429,8 @@ class FileSchema( - to be able to preserve file name info \\"\\"\\" - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: Configuration): - return super(Schema, cls).__new__(cls, arg) + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: Configuration): + return super(Schema, cls).__new__(cls, _arg) class BinaryBase: @@ -6714,24 +7438,24 @@ class BinaryBase: class BinarySchema( - SchemaTypeCheckerClsFactory(typing.Union[bytes, FileIO]), ComposedBase, BinaryBase, Schema, BinaryMixin ): class MetaOapg: - one_of = [ - BytesSchema, - FileSchema, - ] + @staticmethod + def one_of(): + return [ + BytesSchema, + FileSchema, + ] - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: Configuration): - return super().__new__(cls, arg) + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: Configuration): + return super().__new__(cls, _arg) class BoolSchema( - SchemaTypeCheckerClsFactory(typing.Union[BoolClass]), BoolBase, Schema, BoolMixin @@ -6741,14 +7465,11 @@ class BoolSchema( def from_openapi_data_oapg(cls, arg: bool, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: bool, **kwargs: ValidationMetadata): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: bool, **kwargs: ValidationMetadata): + return super().__new__(cls, _arg, **kwargs) class AnyTypeSchema( - SchemaTypeCheckerClsFactory( - typing.Union[frozendict.frozendict, tuple, decimal.Decimal, str, BoolClass, NoneClass, bytes, FileIO] - ), DictBase, ListBase, NumberBase, @@ -6756,7 +7477,7 @@ class AnyTypeSchema( BoolBase, NoneBase, Schema, - NoneFrozenDictTupleStrDecimalBoolMixin + NoneFrozenDictTupleStrDecimalBoolFileBytesMixin ): # Python representation of a schema defined as true or {} pass @@ -6781,18 +7502,17 @@ class NotAnyTypeSchema( def __new__( cls, - *args, + *_args, _configuration: typing.Optional[Configuration] = None, ) -> 'NotAnyTypeSchema': return super().__new__( cls, - *args, + *_args, _configuration=_configuration, ) class DictSchema( - SchemaTypeCheckerClsFactory(typing.Union[frozendict.frozendict]), DictBase, Schema, FrozenDictMixin @@ -6801,14 +7521,14 @@ class DictSchema( def from_openapi_data_oapg(cls, arg: typing.Dict[str, typing.Any], _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, *args: typing.Union[dict, frozendict.frozendict], **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): - return super().__new__(cls, *args, **kwargs) + def __new__(cls, *_args: typing.Union[dict, frozendict.frozendict], **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): + return super().__new__(cls, *_args, **kwargs) schema_type_classes = {NoneSchema, DictSchema, ListSchema, NumberSchema, StrSchema, BoolSchema, AnyTypeSchema} -@functools.cache +@functools.lru_cache() def get_new_class( class_name: str, bases: typing.Tuple[typing.Type[typing.Union[Schema, typing.Any]], ...] @@ -6825,8 +7545,7 @@ LOG_CACHE_USAGE = False def log_cache_usage(cache_fn): if LOG_CACHE_USAGE: - print(cache_fn.__name__, cache_fn.cache_info()) -", + print(cache_fn.__name__, cache_fn.cache_info())", "test/test_models/__init__.py": "", "test/test_models/test_api_error.py": "# coding: utf-8 @@ -6949,7 +7668,7 @@ class ApiTestMixin: ) @staticmethod - def headers_for_content_type(content_type: str) -> dict[str, str]: + def headers_for_content_type(content_type: str) -> typing.Dict[str, str]: return {'content-type': content_type} @classmethod @@ -6958,7 +7677,7 @@ class ApiTestMixin: body: typing.Union[str, bytes], status: int = 200, content_type: str = json_content_type, - headers: typing.Optional[dict[str, str]] = None, + headers: typing.Optional[typing.Dict[str, str]] = None, preload_content: bool = True ) -> urllib3.HTTPResponse: if headers is None: @@ -7037,9 +7756,10 @@ def test_hello(name, expected): assert hello(name) == expected ", "tox.ini": "[tox] -envlist = py39 +envlist = py37 [testenv] +passenv = PYTHON_VERSION deps=-r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt @@ -7049,9 +7769,7 @@ commands= } `; -exports[`Generated Python Client Code Unit Tests Multiple Tags 1`] = `"Operations with multiple tags are not yet supported, please tag operations with at most one tag. The following operations have multiple tags: get /both"`; - -exports[`Generated Python Client Code Unit Tests Single 1`] = ` +exports[`Generated Python Client Code Unit Tests Multiple Tags 1`] = ` Object { ".gitattributes": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". @@ -7216,9 +7934,8 @@ test-3.8: .travis.yml README.md docs/apis/tags/DefaultApi.md -docs/models/ApiError.md -docs/models/TestRequest.md -docs/models/TestResponse.md +docs/apis/tags/Tag1Api.md +docs/apis/tags/Tag2Api.md git_push.sh requirements.txt setup.cfg @@ -7230,25 +7947,18 @@ test/api_client.py test/apis/__init__.py test/apis/tags/default_api.py test/apis/tags/default_api_operation_config.py +test/apis/tags/tag1_api.py +test/apis/tags/tag2_api.py test/configuration.py test/exceptions.py test/model/__init__.py -test/model/api_error.py -test/model/api_error.pyi -test/model/test_request.py -test/model/test_request.pyi -test/model/test_response.py -test/model/test_response.pyi test/models/__init__.py test/rest.py test/schemas.py test/test_models/__init__.py -test/test_models/test_api_error.py -test/test_models/test_test_request.py -test/test_models/test_test_response.py tox.ini ", - ".openapi-generator/VERSION": "6.1.0", + ".openapi-generator/VERSION": "6.3.0", ".projen/deps.json": Object { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", "dependencies": Array [ @@ -7424,13 +8134,11 @@ This Python package is automatically generated by the [OpenAPI Generator](https: - API version: 1.0.0 - Package version: 1.0.0 -- Build package: org.openapitools.codegen.languages.PythonExperimentalClientCodegen +- Build package: org.openapitools.codegen.languages.PythonClientCodegen ## Requirements. -Python >=3.9 -v3.9 is needed so one can combine classmethod and property decorators to define -object schema properties as classes +Python >=3.7 ## Migration from other generators like python and python-legacy @@ -7471,6 +8179,16 @@ object schema properties as classes - A type hint is also generated for additionalProperties accessed using this method - So you will need to update you code to use some_instance['optionalProp'] to access optional property and additionalProperty values +8. The location of the api classes has changed + - Api classes are located in your_package.apis.tags.some_api + - This change was made to eliminate redundant code generation + - Legacy generators generated the same endpoint twice if it had > 1 tag on it + - This generator defines an endpoint in one class, then inherits that class to generate + apis by tags and by paths + - This change reduces code and allows quicker run time if you use the path apis + - path apis are at your_package.apis.paths.some_path + - Those apis will only load their needed models, which is less to load than all of the resources needed in a tag api + - So you will need to update your import paths to the api classes ### Why are Oapg and _oapg used in class and method names? Classes can have arbitrarily named properties set on them @@ -7551,10 +8269,7 @@ Please follow the [installation procedure](#installation--usage) and then run th import time import test from pprint import pprint -from test.apis import default_api -from test.model.api_error import ApiError -from test.model.test_request import TestRequest -from test.model.test_response import TestResponse +from test.apis.tags import default_api # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = test.Configuration( @@ -7566,13 +8281,11 @@ configuration = test.Configuration( with test.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = default_api.DefaultApi(api_client) - body = None # bool, date, datetime, dict, float, int, list, str, none_type | (optional) - + try: - api_response = api_instance.any_request_response(body=body) - pprint(api_response) + api_instance.neither() except test.ApiException as e: - print(\\"Exception when calling DefaultApi->any_request_response: %s\\\\n\\" % e) + print(\\"Exception when calling DefaultApi->neither: %s\\\\n\\" % e) \`\`\` ## Documentation for API Endpoints @@ -7581,17 +8294,13 @@ All URIs are relative to *http://localhost* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*DefaultApi* | [**any_request_response**](docs/apis/tags/DefaultApi.md#any_request_response) | **put** /any-request-response | -*DefaultApi* | [**empty**](docs/apis/tags/DefaultApi.md#empty) | **put** /empty-response | -*DefaultApi* | [**media_types**](docs/apis/tags/DefaultApi.md#media_types) | **post** /different-media-type | -*DefaultApi* | [**operation_one**](docs/apis/tags/DefaultApi.md#operation_one) | **post** /path/{pathParam} | -*DefaultApi* | [**without_operation_id_delete**](docs/apis/tags/DefaultApi.md#without_operation_id_delete) | **delete** /without-operation-id | +*DefaultApi* | [**neither**](docs/apis/tags/DefaultApi.md#neither) | **get** /neither | +*Tag1Api* | [**both**](docs/apis/tags/Tag1Api.md#both) | **get** /both | +*Tag1Api* | [**tag1**](docs/apis/tags/Tag1Api.md#tag1) | **get** /tag1 | +*Tag2Api* | [**tag2**](docs/apis/tags/Tag2Api.md#tag2) | **get** /tag2 | ## Documentation For Models - - [ApiError](docs/models/ApiError.md) - - [TestRequest](docs/models/TestRequest.md) - - [TestResponse](docs/models/TestResponse.md) ## Documentation For Authorization @@ -7601,6 +8310,8 @@ Class | Method | HTTP request | Description + + ## Notes for Large OpenAPI documents If the OpenAPI document is large, imports in test.apis and test.models may fail with a RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions: @@ -7627,15 +8338,11 @@ All URIs are relative to *http://localhost* Method | HTTP request | Description ------------- | ------------- | ------------- -[**any_request_response**](#any_request_response) | **put** /any-request-response | -[**empty**](#empty) | **put** /empty-response | -[**media_types**](#media_types) | **post** /different-media-type | -[**operation_one**](#operation_one) | **post** /path/{pathParam} | -[**without_operation_id_delete**](#without_operation_id_delete) | **delete** /without-operation-id | +[**neither**](#neither) | **get** /neither | -# **any_request_response** - -> bool, date, datetime, dict, float, int, list, str, none_type any_request_response() +# **neither** + +> neither() @@ -7656,57 +8363,8393 @@ with test.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = default_api.DefaultApi(api_client) - # example passing only optional values - body = None + # example, this endpoint has no required or optional parameters try: - api_response = api_instance.any_request_response( - body=body, - ) - pprint(api_response) + api_response = api_instance.neither() except test.ApiException as e: - print(\\"Exception when calling DefaultApi->any_request_response: %s\\\\n\\" % e) + print(\\"Exception when calling DefaultApi->neither: %s\\\\n\\" % e) \`\`\` ### Parameters +This endpoint does not need any parameter. + +### Return Types, Responses +Code | Class | Description +------------- | ------------- | ------------- +n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned +200 | [ApiResponseFor200](#neither.ApiResponseFor200) | Ok + +#### neither.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -body | typing.Union[SchemaForRequestBodyApplicationJson, Unset] | optional, default is unset | -content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body -accept_content_types | typing.Tuple[str] | default is ('application/json', ) | Tells the server the content type(s) that are accepted by the client -stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file +response | urllib3.HTTPResponse | Raw response | +body | Unset | body was not defined | +headers | Unset | headers were not defined | + +### Authorization + +No authorization required + +[[Back to top]](#__pageTop) [[Back to API list]](../../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../../README.md#documentation-for-models) [[Back to README]](../../../README.md) + +", + "docs/apis/tags/Tag1Api.md": " +# test.apis.tags.tag1_api.Tag1Api + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**both**](#both) | **get** /both | +[**tag1**](#tag1) | **get** /tag1 | + +# **both** + +> both() + + + +### Example + +\`\`\`python +import test +from test.apis.tags import tag1_api +from pprint import pprint +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = test.Configuration( + host = \\"http://localhost\\" +) + +# Enter a context with an instance of the API client +with test.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = tag1_api.Tag1Api(api_client) + + # example, this endpoint has no required or optional parameters + try: + api_response = api_instance.both() + except test.ApiException as e: + print(\\"Exception when calling Tag1Api->both: %s\\\\n\\" % e) +\`\`\` +### Parameters +This endpoint does not need any parameter. + +### Return Types, Responses + +Code | Class | Description +------------- | ------------- | ------------- +n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned +200 | [ApiResponseFor200](#both.ApiResponseFor200) | Ok + +#### both.ApiResponseFor200 +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +response | urllib3.HTTPResponse | Raw response | +body | Unset | body was not defined | +headers | Unset | headers were not defined | + +### Authorization + +No authorization required + +[[Back to top]](#__pageTop) [[Back to API list]](../../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../../README.md#documentation-for-models) [[Back to README]](../../../README.md) + +# **tag1** + +> tag1() + + + +### Example + +\`\`\`python +import test +from test.apis.tags import tag1_api +from pprint import pprint +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = test.Configuration( + host = \\"http://localhost\\" +) + +# Enter a context with an instance of the API client +with test.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = tag1_api.Tag1Api(api_client) + + # example, this endpoint has no required or optional parameters + try: + api_response = api_instance.tag1() + except test.ApiException as e: + print(\\"Exception when calling Tag1Api->tag1: %s\\\\n\\" % e) +\`\`\` +### Parameters +This endpoint does not need any parameter. + +### Return Types, Responses + +Code | Class | Description +------------- | ------------- | ------------- +n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned +200 | [ApiResponseFor200](#tag1.ApiResponseFor200) | Ok + +#### tag1.ApiResponseFor200 +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +response | urllib3.HTTPResponse | Raw response | +body | Unset | body was not defined | +headers | Unset | headers were not defined | + +### Authorization + +No authorization required + +[[Back to top]](#__pageTop) [[Back to API list]](../../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../../README.md#documentation-for-models) [[Back to README]](../../../README.md) + +", + "docs/apis/tags/Tag2Api.md": " +# test.apis.tags.tag2_api.Tag2Api + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**tag2**](#tag2) | **get** /tag2 | + +# **tag2** + +> tag2() + + + +### Example + +\`\`\`python +import test +from test.apis.tags import tag2_api +from pprint import pprint +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = test.Configuration( + host = \\"http://localhost\\" +) + +# Enter a context with an instance of the API client +with test.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = tag2_api.Tag2Api(api_client) + + # example, this endpoint has no required or optional parameters + try: + api_response = api_instance.tag2() + except test.ApiException as e: + print(\\"Exception when calling Tag2Api->tag2: %s\\\\n\\" % e) +\`\`\` +### Parameters +This endpoint does not need any parameter. + +### Return Types, Responses + +Code | Class | Description +------------- | ------------- | ------------- +n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned +200 | [ApiResponseFor200](#tag2.ApiResponseFor200) | Ok + +#### tag2.ApiResponseFor200 +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +response | urllib3.HTTPResponse | Raw response | +body | Unset | body was not defined | +headers | Unset | headers were not defined | + +### Authorization + +No authorization required + +[[Back to top]](#__pageTop) [[Back to API list]](../../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../../README.md#documentation-for-models) [[Back to README]](../../../README.md) + +", + "git_push.sh": "#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl \\"minor update\\" \\"gitlab.com\\" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ \\"$git_host\\" = \\"\\" ]; then + git_host=\\"github.com\\" + echo \\"[INFO] No command line input provided. Set \\\\$git_host to $git_host\\" +fi + +if [ \\"$git_user_id\\" = \\"\\" ]; then + git_user_id=\\"GIT_USER_ID\\" + echo \\"[INFO] No command line input provided. Set \\\\$git_user_id to $git_user_id\\" +fi + +if [ \\"$git_repo_id\\" = \\"\\" ]; then + git_repo_id=\\"GIT_REPO_ID\\" + echo \\"[INFO] No command line input provided. Set \\\\$git_repo_id to $git_repo_id\\" +fi + +if [ \\"$release_note\\" = \\"\\" ]; then + release_note=\\"Minor update\\" + echo \\"[INFO] No command line input provided. Set \\\\$release_note to $release_note\\" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m \\"$release_note\\" + +# Sets the new remote +git_remote=\`git remote\` +if [ \\"$git_remote\\" = \\"\\" ]; then # git remote not defined + + if [ \\"$GIT_TOKEN\\" = \\"\\" ]; then + echo \\"[INFO] \\\\$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment.\\" + git remote add origin https://\${git_host}/\${git_user_id}/\${git_repo_id}.git + else + git remote add origin https://\${git_user_id}:\${GIT_TOKEN}@\${git_host}/\${git_user_id}/\${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo \\"Git pushing to https://\${git_host}/\${git_user_id}/\${git_repo_id}.git\\" +git push origin master 2>&1 | grep -v 'To https' + +", + "requirements-dev.txt": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". +projen==99.99.99 +", + "requirements.txt": "certifi >= 14.5.14 +frozendict ~= 2.3.4 +python-dateutil ~= 2.7.0 +setuptools >= 21.0.0 +typing_extensions ~= 4.3.0 +urllib3 ~= 1.26.7 +", + "setup.cfg": "[flake8] +max-line-length=99 +", + "setup.py": "# coding: utf-8 + +\\"\\"\\" + Multiple Tags Test + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from setuptools import setup, find_packages # noqa: H301 + +NAME = \\"test\\" +VERSION = \\"1.0.0\\" +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = [ + \\"certifi >= 14.5.14\\", + \\"frozendict ~= 2.3.4\\", + \\"python-dateutil ~= 2.7.0\\", + \\"setuptools >= 21.0.0\\", + \\"typing_extensions ~= 4.3.0\\", + \\"urllib3 ~= 1.26.7\\", +] + +setup( + name=NAME, + version=VERSION, + description=\\"Multiple Tags Test\\", + author=\\"OpenAPI Generator community\\", + author_email=\\"team@openapitools.org\\", + url=\\"\\", + keywords=[\\"OpenAPI\\", \\"OpenAPI-Generator\\", \\"Multiple Tags Test\\"], + python_requires=\\">=3.7\\", + install_requires=REQUIRES, + packages=find_packages(exclude=[\\"test\\", \\"tests\\"]), + include_package_data=True, + long_description=\\"\\"\\"\\\\ + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + \\"\\"\\" +) +", + "test-requirements.txt": "pytest~=4.6.7 # needed for python 3.4 +pytest-cov>=2.8.1 +pytest-randomly==1.2.3 # needed for python 3.4 +", + "test/__init__.py": "", + "test/__main__.py": "from .example import hello + +if __name__ == \\"__main__\\": + name = input(\\"What is your name? \\") + print(hello(name)) +", + "test/api_client.py": "# coding: utf-8 +\\"\\"\\" + Multiple Tags Test + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from dataclasses import dataclass +from decimal import Decimal +import enum +import email +import json +import os +import io +import atexit +from multiprocessing.pool import ThreadPool +import re +import tempfile +import typing +import typing_extensions +import urllib3 +from urllib3._collections import HTTPHeaderDict +from urllib.parse import urlparse, quote +from urllib3.fields import RequestField as RequestFieldBase + +import frozendict + +from test import rest +from test.configuration import Configuration +from test.exceptions import ApiTypeError, ApiValueError +from test.schemas import ( + NoneClass, + BoolClass, + Schema, + FileIO, + BinarySchema, + date, + datetime, + none_type, + Unset, + unset, +) + + +class RequestField(RequestFieldBase): + def __eq__(self, other): + if not isinstance(other, RequestField): + return False + return self.__dict__ == other.__dict__ + + +class JSONEncoder(json.JSONEncoder): + compact_separators = (',', ':') + + def default(self, obj): + if isinstance(obj, str): + return str(obj) + elif isinstance(obj, float): + return float(obj) + elif isinstance(obj, int): + return int(obj) + elif isinstance(obj, Decimal): + if obj.as_tuple().exponent >= 0: + return int(obj) + return float(obj) + elif isinstance(obj, NoneClass): + return None + elif isinstance(obj, BoolClass): + return bool(obj) + elif isinstance(obj, (dict, frozendict.frozendict)): + return {key: self.default(val) for key, val in obj.items()} + elif isinstance(obj, (list, tuple)): + return [self.default(item) for item in obj] + raise ApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) + + +class ParameterInType(enum.Enum): + QUERY = 'query' + HEADER = 'header' + PATH = 'path' + COOKIE = 'cookie' + + +class ParameterStyle(enum.Enum): + MATRIX = 'matrix' + LABEL = 'label' + FORM = 'form' + SIMPLE = 'simple' + SPACE_DELIMITED = 'spaceDelimited' + PIPE_DELIMITED = 'pipeDelimited' + DEEP_OBJECT = 'deepObject' + + +class PrefixSeparatorIterator: + # A class to store prefixes and separators for rfc6570 expansions + + def __init__(self, prefix: str, separator: str): + self.prefix = prefix + self.separator = separator + self.first = True + if separator in {'.', '|', '%20'}: + item_separator = separator + else: + item_separator = ',' + self.item_separator = item_separator + + def __iter__(self): + return self + + def __next__(self): + if self.first: + self.first = False + return self.prefix + return self.separator + + +class ParameterSerializerBase: + @classmethod + def _get_default_explode(cls, style: ParameterStyle) -> bool: + return False + + @staticmethod + def __ref6570_item_value(in_data: typing.Any, percent_encode: bool): + \\"\\"\\" + Get representation if str/float/int/None/items in list/ values in dict + None is returned if an item is undefined, use cases are value= + - None + - [] + - {} + - [None, None None] + - {'a': None, 'b': None} + \\"\\"\\" + if type(in_data) in {str, float, int}: + if percent_encode: + return quote(str(in_data)) + return str(in_data) + elif isinstance(in_data, none_type): + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return None + elif isinstance(in_data, list) and not in_data: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return None + elif isinstance(in_data, dict) and not in_data: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return None + raise ApiValueError('Unable to generate a ref6570 item representation of {}'.format(in_data)) + + @staticmethod + def _to_dict(name: str, value: str): + return {name: value} + + @classmethod + def __ref6570_str_float_int_expansion( + cls, + variable_name: str, + in_data: typing.Any, + explode: bool, + percent_encode: bool, + prefix_separator_iterator: PrefixSeparatorIterator, + var_name_piece: str, + named_parameter_expansion: bool + ) -> str: + item_value = cls.__ref6570_item_value(in_data, percent_encode) + if item_value is None or (item_value == '' and prefix_separator_iterator.separator == ';'): + return next(prefix_separator_iterator) + var_name_piece + value_pair_equals = '=' if named_parameter_expansion else '' + return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value + + @classmethod + def __ref6570_list_expansion( + cls, + variable_name: str, + in_data: typing.Any, + explode: bool, + percent_encode: bool, + prefix_separator_iterator: PrefixSeparatorIterator, + var_name_piece: str, + named_parameter_expansion: bool + ) -> str: + item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data] + item_values = [v for v in item_values if v is not None] + if not item_values: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return \\"\\" + value_pair_equals = '=' if named_parameter_expansion else '' + if not explode: + return ( + next(prefix_separator_iterator) + + var_name_piece + + value_pair_equals + + prefix_separator_iterator.item_separator.join(item_values) + ) + # exploded + return next(prefix_separator_iterator) + next(prefix_separator_iterator).join( + [var_name_piece + value_pair_equals + val for val in item_values] + ) + + @classmethod + def __ref6570_dict_expansion( + cls, + variable_name: str, + in_data: typing.Any, + explode: bool, + percent_encode: bool, + prefix_separator_iterator: PrefixSeparatorIterator, + var_name_piece: str, + named_parameter_expansion: bool + ) -> str: + in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()} + in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None} + if not in_data_transformed: + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return \\"\\" + value_pair_equals = '=' if named_parameter_expansion else '' + if not explode: + return ( + next(prefix_separator_iterator) + + var_name_piece + value_pair_equals + + prefix_separator_iterator.item_separator.join( + prefix_separator_iterator.item_separator.join( + item_pair + ) for item_pair in in_data_transformed.items() + ) + ) + # exploded + return next(prefix_separator_iterator) + next(prefix_separator_iterator).join( + [key + '=' + val for key, val in in_data_transformed.items()] + ) + + @classmethod + def _ref6570_expansion( + cls, + variable_name: str, + in_data: typing.Any, + explode: bool, + percent_encode: bool, + prefix_separator_iterator: PrefixSeparatorIterator + ) -> str: + \\"\\"\\" + Separator is for separate variables like dict with explode true, not for array item separation + \\"\\"\\" + named_parameter_expansion = prefix_separator_iterator.separator in {'&', ';'} + var_name_piece = variable_name if named_parameter_expansion else '' + if type(in_data) in {str, float, int}: + return cls.__ref6570_str_float_int_expansion( + variable_name, + in_data, + explode, + percent_encode, + prefix_separator_iterator, + var_name_piece, + named_parameter_expansion + ) + elif isinstance(in_data, none_type): + # ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1 + return \\"\\" + elif isinstance(in_data, list): + return cls.__ref6570_list_expansion( + variable_name, + in_data, + explode, + percent_encode, + prefix_separator_iterator, + var_name_piece, + named_parameter_expansion + ) + elif isinstance(in_data, dict): + return cls.__ref6570_dict_expansion( + variable_name, + in_data, + explode, + percent_encode, + prefix_separator_iterator, + var_name_piece, + named_parameter_expansion + ) + # bool, bytes, etc + raise ApiValueError('Unable to generate a ref6570 representation of {}'.format(in_data)) + + +class StyleFormSerializer(ParameterSerializerBase): + @classmethod + def _get_default_explode(cls, style: ParameterStyle) -> bool: + if style is ParameterStyle.FORM: + return True + return super()._get_default_explode(style) + + def _serialize_form( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + name: str, + explode: bool, + percent_encode: bool, + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None + ) -> str: + if prefix_separator_iterator is None: + prefix_separator_iterator = PrefixSeparatorIterator('', '&') + return self._ref6570_expansion( + variable_name=name, + in_data=in_data, + explode=explode, + percent_encode=percent_encode, + prefix_separator_iterator=prefix_separator_iterator + ) + + +class StyleSimpleSerializer(ParameterSerializerBase): + + def _serialize_simple( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + name: str, + explode: bool, + percent_encode: bool + ) -> str: + prefix_separator_iterator = PrefixSeparatorIterator('', ',') + return self._ref6570_expansion( + variable_name=name, + in_data=in_data, + explode=explode, + percent_encode=percent_encode, + prefix_separator_iterator=prefix_separator_iterator + ) + + +class JSONDetector: + \\"\\"\\" + Works for: + application/json + application/json; charset=UTF-8 + application/json-patch+json + application/geo+json + \\"\\"\\" + __json_content_type_pattern = re.compile(\\"application/[^+]*[+]?(json);?.*\\") + + @classmethod + def _content_type_is_json(cls, content_type: str) -> bool: + if cls.__json_content_type_pattern.match(content_type): + return True + return False + + +@dataclass +class ParameterBase(JSONDetector): + name: str + in_type: ParameterInType + required: bool + style: typing.Optional[ParameterStyle] + explode: typing.Optional[bool] + allow_reserved: typing.Optional[bool] + schema: typing.Optional[typing.Type[Schema]] + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] + + __style_to_in_type = { + ParameterStyle.MATRIX: {ParameterInType.PATH}, + ParameterStyle.LABEL: {ParameterInType.PATH}, + ParameterStyle.FORM: {ParameterInType.QUERY, ParameterInType.COOKIE}, + ParameterStyle.SIMPLE: {ParameterInType.PATH, ParameterInType.HEADER}, + ParameterStyle.SPACE_DELIMITED: {ParameterInType.QUERY}, + ParameterStyle.PIPE_DELIMITED: {ParameterInType.QUERY}, + ParameterStyle.DEEP_OBJECT: {ParameterInType.QUERY}, + } + __in_type_to_default_style = { + ParameterInType.QUERY: ParameterStyle.FORM, + ParameterInType.PATH: ParameterStyle.SIMPLE, + ParameterInType.HEADER: ParameterStyle.SIMPLE, + ParameterInType.COOKIE: ParameterStyle.FORM, + } + __disallowed_header_names = {'Accept', 'Content-Type', 'Authorization'} + _json_encoder = JSONEncoder() + + @classmethod + def __verify_style_to_in_type(cls, style: typing.Optional[ParameterStyle], in_type: ParameterInType): + if style is None: + return + in_type_set = cls.__style_to_in_type[style] + if in_type not in in_type_set: + raise ValueError( + 'Invalid style and in_type combination. For style={} only in_type={} are allowed'.format( + style, in_type_set + ) + ) + + def __init__( + self, + name: str, + in_type: ParameterInType, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + if schema is None and content is None: + raise ValueError('Value missing; Pass in either schema or content') + if schema and content: + raise ValueError('Too many values provided. Both schema and content were provided. Only one may be input') + if name in self.__disallowed_header_names and in_type is ParameterInType.HEADER: + raise ValueError('Invalid name, name may not be one of {}'.format(self.__disallowed_header_names)) + self.__verify_style_to_in_type(style, in_type) + if content is None and style is None: + style = self.__in_type_to_default_style[in_type] + if content is not None and in_type in self.__in_type_to_default_style and len(content) != 1: + raise ValueError('Invalid content length, content length must equal 1') + self.in_type = in_type + self.name = name + self.required = required + self.style = style + self.explode = explode + self.allow_reserved = allow_reserved + self.schema = schema + self.content = content + + def _serialize_json( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + eliminate_whitespace: bool = False + ) -> str: + if eliminate_whitespace: + return json.dumps(in_data, separators=self._json_encoder.compact_separators) + return json.dumps(in_data) + + +class PathParameter(ParameterBase, StyleSimpleSerializer): + + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + super().__init__( + name, + in_type=ParameterInType.PATH, + required=required, + style=style, + explode=explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + def __serialize_label( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list] + ) -> typing.Dict[str, str]: + prefix_separator_iterator = PrefixSeparatorIterator('.', '.') + value = self._ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self._to_dict(self.name, value) + + def __serialize_matrix( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list] + ) -> typing.Dict[str, str]: + prefix_separator_iterator = PrefixSeparatorIterator(';', ';') + value = self._ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self._to_dict(self.name, value) + + def __serialize_simple( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + ) -> typing.Dict[str, str]: + value = self._serialize_simple( + in_data=in_data, + name=self.name, + explode=self.explode, + percent_encode=True + ) + return self._to_dict(self.name, value) + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict.frozendict] + ) -> typing.Dict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + \\"\\"\\" + simple -> path + path: + returns path_params: dict + label -> path + returns path_params + matrix -> path + returns path_params + \\"\\"\\" + if self.style: + if self.style is ParameterStyle.SIMPLE: + return self.__serialize_simple(cast_in_data) + elif self.style is ParameterStyle.LABEL: + return self.__serialize_label(cast_in_data) + elif self.style is ParameterStyle.MATRIX: + return self.__serialize_matrix(cast_in_data) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if self._content_type_is_json(content_type): + value = self._serialize_json(cast_in_data) + return self._to_dict(self.name, value) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class QueryParameter(ParameterBase, StyleFormSerializer): + + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: typing.Optional[bool] = None, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + used_style = ParameterStyle.FORM if style is None else style + used_explode = self._get_default_explode(used_style) if explode is None else explode + + super().__init__( + name, + in_type=ParameterInType.QUERY, + required=required, + style=used_style, + explode=used_explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + def __serialize_space_delimited( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] + ) -> typing.Dict[str, str]: + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + value = self._ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self._to_dict(self.name, value) + + def __serialize_pipe_delimited( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] + ) -> typing.Dict[str, str]: + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + value = self._ref6570_expansion( + variable_name=self.name, + in_data=in_data, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self._to_dict(self.name, value) + + def __serialize_form( + self, + in_data: typing.Union[None, int, float, str, bool, dict, list], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] + ) -> typing.Dict[str, str]: + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + value = self._serialize_form( + in_data, + name=self.name, + explode=self.explode, + percent_encode=True, + prefix_separator_iterator=prefix_separator_iterator + ) + return self._to_dict(self.name, value) + + def get_prefix_separator_iterator(self) -> typing.Optional[PrefixSeparatorIterator]: + if self.style is ParameterStyle.FORM: + return PrefixSeparatorIterator('?', '&') + elif self.style is ParameterStyle.SPACE_DELIMITED: + return PrefixSeparatorIterator('', '%20') + elif self.style is ParameterStyle.PIPE_DELIMITED: + return PrefixSeparatorIterator('', '|') + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict.frozendict], + prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None + ) -> typing.Dict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + \\"\\"\\" + form -> query + query: + - GET/HEAD/DELETE: could use fields + - PUT/POST: must use urlencode to send parameters + returns fields: tuple + spaceDelimited -> query + returns fields + pipeDelimited -> query + returns fields + deepObject -> query, https://github.com/OAI/OpenAPI-Specification/issues/1706 + returns fields + \\"\\"\\" + if self.style: + # TODO update query ones to omit setting values when [] {} or None is input + if self.style is ParameterStyle.FORM: + return self.__serialize_form(cast_in_data, prefix_separator_iterator) + elif self.style is ParameterStyle.SPACE_DELIMITED: + return self.__serialize_space_delimited(cast_in_data, prefix_separator_iterator) + elif self.style is ParameterStyle.PIPE_DELIMITED: + return self.__serialize_pipe_delimited(cast_in_data, prefix_separator_iterator) + # self.content will be length one + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if self._content_type_is_json(content_type): + value = self._serialize_json(cast_in_data, eliminate_whitespace=True) + return self._to_dict( + self.name, + next(prefix_separator_iterator) + self.name + '=' + quote(value) + ) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class CookieParameter(ParameterBase, StyleFormSerializer): + + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: typing.Optional[bool] = None, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + used_style = ParameterStyle.FORM if style is None and content is None and schema else style + used_explode = self._get_default_explode(used_style) if explode is None else explode + + super().__init__( + name, + in_type=ParameterInType.COOKIE, + required=required, + style=used_style, + explode=used_explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict.frozendict] + ) -> typing.Dict[str, str]: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + \\"\\"\\" + form -> cookie + returns fields: tuple + \\"\\"\\" + if self.style: + \\"\\"\\" + TODO add escaping of comma, space, equals + or turn encoding on + \\"\\"\\" + value = self._serialize_form( + cast_in_data, + explode=self.explode, + name=self.name, + percent_encode=False, + prefix_separator_iterator=PrefixSeparatorIterator('', '&') + ) + return self._to_dict(self.name, value) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if self._content_type_is_json(content_type): + value = self._serialize_json(cast_in_data) + return self._to_dict(self.name, value) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class HeaderParameter(ParameterBase, StyleSimpleSerializer): + def __init__( + self, + name: str, + required: bool = False, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: typing.Optional[bool] = None, + schema: typing.Optional[typing.Type[Schema]] = None, + content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None + ): + super().__init__( + name, + in_type=ParameterInType.HEADER, + required=required, + style=style, + explode=explode, + allow_reserved=allow_reserved, + schema=schema, + content=content + ) + + @staticmethod + def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict: + data = tuple(t for t in in_data if t) + headers = HTTPHeaderDict() + if not data: + return headers + headers.extend(data) + return headers + + def serialize( + self, + in_data: typing.Union[ + Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict.frozendict] + ) -> HTTPHeaderDict: + if self.schema: + cast_in_data = self.schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + \\"\\"\\" + simple -> header + headers: PoolManager needs a mapping, tuple is close + returns headers: dict + \\"\\"\\" + if self.style: + value = self._serialize_simple(cast_in_data, self.name, self.explode, False) + return self.__to_headers(((self.name, value),)) + # self.content will be length one + for content_type, schema in self.content.items(): + cast_in_data = schema(in_data) + cast_in_data = self._json_encoder.default(cast_in_data) + if self._content_type_is_json(content_type): + value = self._serialize_json(cast_in_data) + return self.__to_headers(((self.name, value),)) + raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) + + +class Encoding: + def __init__( + self, + content_type: str, + headers: typing.Optional[typing.Dict[str, HeaderParameter]] = None, + style: typing.Optional[ParameterStyle] = None, + explode: bool = False, + allow_reserved: bool = False, + ): + self.content_type = content_type + self.headers = headers + self.style = style + self.explode = explode + self.allow_reserved = allow_reserved + + +@dataclass +class MediaType: + \\"\\"\\" + Used to store request and response body schema information + encoding: + A map between a property name and its encoding information. + The key, being the property name, MUST exist in the schema as a property. + The encoding object SHALL only apply to requestBody objects when the media type is + multipart or application/x-www-form-urlencoded. + \\"\\"\\" + schema: typing.Optional[typing.Type[Schema]] = None + encoding: typing.Optional[typing.Dict[str, Encoding]] = None + + +@dataclass +class ApiResponse: + response: urllib3.HTTPResponse + body: typing.Union[Unset, Schema] = unset + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset + + def __init__( + self, + response: urllib3.HTTPResponse, + body: typing.Union[Unset, Schema] = unset, + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset + ): + \\"\\"\\" + pycharm needs this to prevent 'Unexpected argument' warnings + \\"\\"\\" + self.response = response + self.body = body + self.headers = headers + + +@dataclass +class ApiResponseWithoutDeserialization(ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[Unset, typing.Type[Schema]] = unset + headers: typing.Union[Unset, typing.List[HeaderParameter]] = unset + + +class OpenApiResponse(JSONDetector): + __filename_content_disposition_pattern = re.compile('filename=\\"(.+?)\\"') + + def __init__( + self, + response_cls: typing.Type[ApiResponse] = ApiResponse, + content: typing.Optional[typing.Dict[str, MediaType]] = None, + headers: typing.Optional[typing.List[HeaderParameter]] = None, + ): + self.headers = headers + if content is not None and len(content) == 0: + raise ValueError('Invalid value for content, the content dict must have >= 1 entry') + self.content = content + self.response_cls = response_cls + + @staticmethod + def __deserialize_json(response: urllib3.HTTPResponse) -> typing.Any: + # python must be >= 3.9 so we can pass in bytes into json.loads + return json.loads(response.data) + + @staticmethod + def __file_name_from_response_url(response_url: typing.Optional[str]) -> typing.Optional[str]: + if response_url is None: + return None + url_path = urlparse(response_url).path + if url_path: + path_basename = os.path.basename(url_path) + if path_basename: + _filename, ext = os.path.splitext(path_basename) + if ext: + return path_basename + return None + + @classmethod + def __file_name_from_content_disposition(cls, content_disposition: typing.Optional[str]) -> typing.Optional[str]: + if content_disposition is None: + return None + match = cls.__filename_content_disposition_pattern.search(content_disposition) + if not match: + return None + return match.group(1) + + def __deserialize_application_octet_stream( + self, response: urllib3.HTTPResponse + ) -> typing.Union[bytes, io.BufferedReader]: + \\"\\"\\" + urllib3 use cases: + 1. when preload_content=True (stream=False) then supports_chunked_reads is False and bytes are returned + 2. when preload_content=False (stream=True) then supports_chunked_reads is True and + a file will be written and returned + \\"\\"\\" + if response.supports_chunked_reads(): + file_name = ( + self.__file_name_from_content_disposition(response.headers.get('content-disposition')) + or self.__file_name_from_response_url(response.geturl()) + ) + + if file_name is None: + _fd, path = tempfile.mkstemp() + else: + path = os.path.join(tempfile.gettempdir(), file_name) + + with open(path, 'wb') as new_file: + chunk_size = 1024 + while True: + data = response.read(chunk_size) + if not data: + break + new_file.write(data) + # release_conn is needed for streaming connections only + response.release_conn() + new_file = open(path, 'rb') + return new_file + else: + return response.data + + @staticmethod + def __deserialize_multipart_form_data( + response: urllib3.HTTPResponse + ) -> typing.Dict[str, typing.Any]: + msg = email.message_from_bytes(response.data) + return { + part.get_param(\\"name\\", header=\\"Content-Disposition\\"): part.get_payload( + decode=True + ).decode(part.get_content_charset()) + if part.get_content_charset() + else part.get_payload() + for part in msg.get_payload() + } + + def deserialize(self, response: urllib3.HTTPResponse, configuration: Configuration) -> ApiResponse: + content_type = response.getheader('content-type') + deserialized_body = unset + streamed = response.supports_chunked_reads() + + deserialized_headers = unset + if self.headers is not None: + # TODO add header deserialiation here + pass + + if self.content is not None: + if content_type not in self.content: + raise ApiValueError( + f\\"Invalid content_type returned. Content_type='{content_type}' was returned \\" + f\\"when only {str(set(self.content))} are defined for status_code={str(response.status)}\\" + ) + body_schema = self.content[content_type].schema + if body_schema is None: + # some specs do not define response content media type schemas + return self.response_cls( + response=response, + headers=deserialized_headers, + body=unset + ) + + if self._content_type_is_json(content_type): + body_data = self.__deserialize_json(response) + elif content_type == 'application/octet-stream': + body_data = self.__deserialize_application_octet_stream(response) + elif content_type.startswith('multipart/form-data'): + body_data = self.__deserialize_multipart_form_data(response) + content_type = 'multipart/form-data' + else: + raise NotImplementedError('Deserialization of {} has not yet been implemented'.format(content_type)) + deserialized_body = body_schema.from_openapi_data_oapg( + body_data, _configuration=configuration) + elif streamed: + response.release_conn() + + return self.response_cls( + response=response, + headers=deserialized_headers, + body=deserialized_body + ) + + +class ApiClient: + \\"\\"\\"Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + \\"\\"\\" + + _pool = None + + def __init__( + self, + configuration: typing.Optional[Configuration] = None, + header_name: typing.Optional[str] = None, + header_value: typing.Optional[str] = None, + cookie: typing.Optional[str] = None, + pool_threads: int = 1 + ): + if configuration is None: + configuration = Configuration() + self.configuration = configuration + self.pool_threads = pool_threads + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = HTTPHeaderDict() + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = 'OpenAPI-Generator/1.0.0/python' + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + \\"\\"\\"Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + \\"\\"\\" + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def user_agent(self): + \\"\\"\\"User agent for this API client\\"\\"\\" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + def __call_api( + self, + resource_path: str, + method: str, + headers: typing.Optional[HTTPHeaderDict] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + host: typing.Optional[str] = None, + ) -> urllib3.HTTPResponse: + + # header parameters + used_headers = HTTPHeaderDict(self.default_headers) + if self.cookie: + headers['Cookie'] = self.cookie + + # auth setting + self.update_params_for_auth(used_headers, + auth_settings, resource_path, method, body) + + # must happen after cookie setting and auth setting in case user is overriding those + if headers: + used_headers.update(headers) + + # request url + if host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = host + resource_path + + # perform request and return response + response = self.request( + method, + url, + headers=used_headers, + fields=fields, + body=body, + stream=stream, + timeout=timeout, + ) + return response + + def call_api( + self, + resource_path: str, + method: str, + headers: typing.Optional[HTTPHeaderDict] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + async_req: typing.Optional[bool] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + host: typing.Optional[str] = None, + ) -> urllib3.HTTPResponse: + \\"\\"\\"Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param headers: Header parameters to be + placed in the request header. + :param body: Request body. + :param fields: Request post form parameters, + for \`application/x-www-form-urlencoded\`, \`multipart/form-data\`. + :param auth_settings: Auth Settings names for the request. + :param async_req: execute request asynchronously + :type async_req: bool, optional TODO remove, unused + :param stream: if True, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Also when True, if the openapi spec describes a file download, + the data will be written to a local filesystme file and the BinarySchema + instance will also inherit from FileSchema and FileIO + Default is False. + :type stream: bool, optional + :param timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param host: api endpoint host + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + \\"\\"\\" + + if not async_req: + return self.__call_api( + resource_path, + method, + headers, + body, + fields, + auth_settings, + stream, + timeout, + host, + ) + + return self.pool.apply_async( + self.__call_api, + ( + resource_path, + method, + headers, + body, + json, + fields, + auth_settings, + stream, + timeout, + host, + ) + ) + + def request( + self, + method: str, + url: str, + headers: typing.Optional[HTTPHeaderDict] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> urllib3.HTTPResponse: + \\"\\"\\"Makes the HTTP request using RESTClient.\\"\\"\\" + if method == \\"GET\\": + return self.rest_client.GET(url, + stream=stream, + timeout=timeout, + headers=headers) + elif method == \\"HEAD\\": + return self.rest_client.HEAD(url, + stream=stream, + timeout=timeout, + headers=headers) + elif method == \\"OPTIONS\\": + return self.rest_client.OPTIONS(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == \\"POST\\": + return self.rest_client.POST(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == \\"PUT\\": + return self.rest_client.PUT(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == \\"PATCH\\": + return self.rest_client.PATCH(url, + headers=headers, + fields=fields, + stream=stream, + timeout=timeout, + body=body) + elif method == \\"DELETE\\": + return self.rest_client.DELETE(url, + headers=headers, + stream=stream, + timeout=timeout, + body=body) + else: + raise ApiValueError( + \\"http method must be \`GET\`, \`HEAD\`, \`OPTIONS\`,\\" + \\" \`POST\`, \`PATCH\`, \`PUT\` or \`DELETE\`.\\" + ) + + def update_params_for_auth(self, headers, auth_settings, + resource_path, method, body): + \\"\\"\\"Updates header and query params based on authentication setting. + + :param headers: Header parameters dict to be updated. + :param auth_settings: Authentication setting identifiers list. + :param resource_path: A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method. + :param body: A object representing the body of the HTTP request. + The object type is the return value of _encoder.default(). + \\"\\"\\" + if not auth_settings: + return + + for auth in auth_settings: + auth_setting = self.configuration.auth_settings().get(auth) + if not auth_setting: + continue + if auth_setting['in'] == 'cookie': + headers.add('Cookie', auth_setting['value']) + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers.add(auth_setting['key'], auth_setting['value']) + elif auth_setting['in'] == 'query': + \\"\\"\\" TODO implement auth in query + need to pass in prefix_separator_iterator + and need to output resource_path with query params added + \\"\\"\\" + raise ApiValueError(\\"Auth in query not yet implemented\\") + else: + raise ApiValueError( + 'Authentication token must be in \`query\` or \`header\`' + ) + + +class Api: + \\"\\"\\"NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + \\"\\"\\" + + def __init__(self, api_client: typing.Optional[ApiClient] = None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client + + @staticmethod + def _verify_typed_dict_inputs_oapg(cls: typing.Type[typing_extensions.TypedDict], data: typing.Dict[str, typing.Any]): + \\"\\"\\" + Ensures that: + - required keys are present + - additional properties are not input + - value stored under required keys do not have the value unset + Note: detailed value checking is done in schema classes + \\"\\"\\" + missing_required_keys = [] + required_keys_with_unset_values = [] + for required_key in cls.__required_keys__: + if required_key not in data: + missing_required_keys.append(required_key) + continue + value = data[required_key] + if value is unset: + required_keys_with_unset_values.append(required_key) + if missing_required_keys: + raise ApiTypeError( + '{} missing {} required arguments: {}'.format( + cls.__name__, len(missing_required_keys), missing_required_keys + ) + ) + if required_keys_with_unset_values: + raise ApiValueError( + '{} contains invalid unset values for {} required keys: {}'.format( + cls.__name__, len(required_keys_with_unset_values), required_keys_with_unset_values + ) + ) + + disallowed_additional_keys = [] + for key in data: + if key in cls.__required_keys__ or key in cls.__optional_keys__: + continue + disallowed_additional_keys.append(key) + if disallowed_additional_keys: + raise ApiTypeError( + '{} got {} unexpected keyword arguments: {}'.format( + cls.__name__, len(disallowed_additional_keys), disallowed_additional_keys + ) + ) + + def _get_host_oapg( + self, + operation_id: str, + servers: typing.Tuple[typing.Dict[str, str], ...] = tuple(), + host_index: typing.Optional[int] = None + ) -> typing.Optional[str]: + configuration = self.api_client.configuration + try: + if host_index is None: + index = configuration.server_operation_index.get( + operation_id, configuration.server_index + ) + else: + index = host_index + server_variables = configuration.server_operation_variables.get( + operation_id, configuration.server_variables + ) + host = configuration.get_host_from_settings( + index, variables=server_variables, servers=servers + ) + except IndexError: + if servers: + raise ApiValueError( + \\"Invalid host index. Must be 0 <= index < %s\\" % + len(servers) + ) + host = None + return host + + +class SerializedRequestBody(typing_extensions.TypedDict, total=False): + body: typing.Union[str, bytes] + fields: typing.Tuple[typing.Union[RequestField, typing.Tuple[str, str]], ...] + + +class RequestBody(StyleFormSerializer, JSONDetector): + \\"\\"\\" + A request body parameter + content: content_type to MediaType Schema info + \\"\\"\\" + __json_encoder = JSONEncoder() + + def __init__( + self, + content: typing.Dict[str, MediaType], + required: bool = False, + ): + self.required = required + if len(content) == 0: + raise ValueError('Invalid value for content, the content dict must have >= 1 entry') + self.content = content + + def __serialize_json( + self, + in_data: typing.Any + ) -> typing.Dict[str, bytes]: + in_data = self.__json_encoder.default(in_data) + json_str = json.dumps(in_data, separators=(\\",\\", \\":\\"), ensure_ascii=False).encode( + \\"utf-8\\" + ) + return dict(body=json_str) + + @staticmethod + def __serialize_text_plain(in_data: typing.Any) -> typing.Dict[str, str]: + if isinstance(in_data, frozendict.frozendict): + raise ValueError('Unable to serialize type frozendict.frozendict to text/plain') + elif isinstance(in_data, tuple): + raise ValueError('Unable to serialize type tuple to text/plain') + elif isinstance(in_data, NoneClass): + raise ValueError('Unable to serialize type NoneClass to text/plain') + elif isinstance(in_data, BoolClass): + raise ValueError('Unable to serialize type BoolClass to text/plain') + return dict(body=str(in_data)) + + def __multipart_json_item(self, key: str, value: Schema) -> RequestField: + json_value = self.__json_encoder.default(value) + request_field = RequestField(name=key, data=json.dumps(json_value)) + request_field.make_multipart(content_type='application/json') + return request_field + + def __multipart_form_item(self, key: str, value: Schema) -> RequestField: + if isinstance(value, str): + request_field = RequestField(name=key, data=str(value)) + request_field.make_multipart(content_type='text/plain') + elif isinstance(value, bytes): + request_field = RequestField(name=key, data=value) + request_field.make_multipart(content_type='application/octet-stream') + elif isinstance(value, FileIO): + # TODO use content.encoding to limit allowed content types if they are present + request_field = RequestField.from_tuples(key, (os.path.basename(value.name), value.read())) + value.close() + else: + request_field = self.__multipart_json_item(key=key, value=value) + return request_field + + def __serialize_multipart_form_data( + self, in_data: Schema + ) -> typing.Dict[str, typing.Tuple[RequestField, ...]]: + if not isinstance(in_data, frozendict.frozendict): + raise ValueError(f'Unable to serialize {in_data} to multipart/form-data because it is not a dict of data') + \\"\\"\\" + In a multipart/form-data request body, each schema property, or each element of a schema array property, + takes a section in the payload with an internal header as defined by RFC7578. The serialization strategy + for each property of a multipart/form-data request body can be specified in an associated Encoding Object. + + When passing in multipart types, boundaries MAY be used to separate sections of the content being + transferred – thus, the following default Content-Types are defined for multipart: + + If the (object) property is a primitive, or an array of primitive values, the default Content-Type is text/plain + If the property is complex, or an array of complex values, the default Content-Type is application/json + Question: how is the array of primitives encoded? + If the property is a type: string with a contentEncoding, the default Content-Type is application/octet-stream + \\"\\"\\" + fields = [] + for key, value in in_data.items(): + if isinstance(value, tuple): + if value: + # values use explode = True, so the code makes a RequestField for each item with name=key + for item in value: + request_field = self.__multipart_form_item(key=key, value=item) + fields.append(request_field) + else: + # send an empty array as json because exploding will not send it + request_field = self.__multipart_json_item(key=key, value=value) + fields.append(request_field) + else: + request_field = self.__multipart_form_item(key=key, value=value) + fields.append(request_field) + + return dict(fields=tuple(fields)) + + def __serialize_application_octet_stream(self, in_data: BinarySchema) -> typing.Dict[str, bytes]: + if isinstance(in_data, bytes): + return dict(body=in_data) + # FileIO type + result = dict(body=in_data.read()) + in_data.close() + return result + + def __serialize_application_x_www_form_data( + self, in_data: typing.Any + ) -> SerializedRequestBody: + \\"\\"\\" + POST submission of form data in body + \\"\\"\\" + if not isinstance(in_data, frozendict.frozendict): + raise ValueError( + f'Unable to serialize {in_data} to application/x-www-form-urlencoded because it is not a dict of data') + cast_in_data = self.__json_encoder.default(in_data) + value = self._serialize_form(cast_in_data, name='', explode=True, percent_encode=True) + return dict(body=value) + + def serialize( + self, in_data: typing.Any, content_type: str + ) -> SerializedRequestBody: + \\"\\"\\" + If a str is returned then the result will be assigned to data when making the request + If a tuple is returned then the result will be used as fields input in encode_multipart_formdata + Return a tuple of + + The key of the return dict is + - body for application/json + - encode_multipart and fields for multipart/form-data + \\"\\"\\" + media_type = self.content[content_type] + if isinstance(in_data, media_type.schema): + cast_in_data = in_data + elif isinstance(in_data, (dict, frozendict.frozendict)) and in_data: + cast_in_data = media_type.schema(**in_data) + else: + cast_in_data = media_type.schema(in_data) + # TODO check for and use encoding if it exists + # and content_type is multipart or application/x-www-form-urlencoded + if self._content_type_is_json(content_type): + return self.__serialize_json(cast_in_data) + elif content_type == 'text/plain': + return self.__serialize_text_plain(cast_in_data) + elif content_type == 'multipart/form-data': + return self.__serialize_multipart_form_data(cast_in_data) + elif content_type == 'application/x-www-form-urlencoded': + return self.__serialize_application_x_www_form_data(cast_in_data) + elif content_type == 'application/octet-stream': + return self.__serialize_application_octet_stream(cast_in_data) + raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type))", + "test/apis/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames +# if you need the ability to import all endpoints then import them from +# tags, paths, or path_to_api, or tag_to_api", + "test/apis/path_to_api.py": "import typing_extensions + +from test.paths import PathValues +from test.apis.paths.tag1 import Tag1 +from test.apis.paths.tag2 import Tag2 +from test.apis.paths.both import Both +from test.apis.paths.neither import Neither + +PathToApi = typing_extensions.TypedDict( + 'PathToApi', + { + PathValues.TAG1: Tag1, + PathValues.TAG2: Tag2, + PathValues.BOTH: Both, + PathValues.NEITHER: Neither, + } +) + +path_to_api = PathToApi( + { + PathValues.TAG1: Tag1, + PathValues.TAG2: Tag2, + PathValues.BOTH: Both, + PathValues.NEITHER: Neither, + } +) +", + "test/apis/paths/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames +# if you need the ability to import all endpoints from this module, import them with +# from test.apis.path_to_api import path_to_api +", + "test/apis/paths/both.py": "from test.paths.both.get import ApiForget + + +class Both( + ApiForget, +): + pass +", + "test/apis/paths/neither.py": "from test.paths.neither.get import ApiForget + + +class Neither( + ApiForget, +): + pass +", + "test/apis/paths/tag1.py": "from test.paths.tag1.get import ApiForget + + +class Tag1( + ApiForget, +): + pass +", + "test/apis/paths/tag2.py": "from test.paths.tag2.get import ApiForget + + +class Tag2( + ApiForget, +): + pass +", + "test/apis/tag_to_api.py": "import typing_extensions + +from test.apis.tags import TagValues +from test.apis.tags.default_api import DefaultApi +from test.apis.tags.tag1_api import Tag1Api +from test.apis.tags.tag2_api import Tag2Api + +TagToApi = typing_extensions.TypedDict( + 'TagToApi', + { + TagValues.DEFAULT: DefaultApi, + TagValues.TAG1: Tag1Api, + TagValues.TAG2: Tag2Api, + } +) + +tag_to_api = TagToApi( + { + TagValues.DEFAULT: DefaultApi, + TagValues.TAG1: Tag1Api, + TagValues.TAG2: Tag2Api, + } +) +", + "test/apis/tags/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames +# if you need the ability to import all endpoints from this module, import them with +# from test.apis.tag_to_api import tag_to_api + +import enum + + +class TagValues(str, enum.Enum): + DEFAULT = \\"default\\" + TAG1 = \\"tag1\\" + TAG2 = \\"tag2\\" +", + "test/apis/tags/default_api.py": "# coding: utf-8 + +\\"\\"\\" + Multiple Tags Test + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from test.paths.neither.get import Neither + + +class DefaultApi( + Neither, +): + \\"\\"\\"NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + \\"\\"\\" + pass +", + "test/apis/tags/default_api_operation_config.py": "import urllib.parse +import json +from typing import Callable, Any, Dict, List, NamedTuple, TypeVar, Generic, Union, TypedDict, Protocol, Optional, Literal +from functools import wraps +from dataclasses import dataclass, fields + + +from test.schemas import ( + date, + datetime, + file_type, + none_type, +) +from test.api_client import JSONEncoder + +T = TypeVar('T') + +# Generic type for object keyed by operation names +@dataclass +class OperationConfig(Generic[T]): + neither: T + both: T + tag1: T + tag2: T + ... + +# Look up path and http method for a given operation name +OperationLookup = { + \\"neither\\": { + \\"path\\": \\"/neither\\", + \\"method\\": \\"get\\", + }, + \\"both\\": { + \\"path\\": \\"/both\\", + \\"method\\": \\"get\\", + }, + \\"tag1\\": { + \\"path\\": \\"/tag1\\", + \\"method\\": \\"get\\", + }, + \\"tag2\\": { + \\"path\\": \\"/tag2\\", + \\"method\\": \\"get\\", + }, +} + +class Operations: + @staticmethod + def all(value: T) -> OperationConfig[T]: + \\"\\"\\" + Returns an OperationConfig with the same value for every operation + \\"\\"\\" + return OperationConfig(**{ operation_id: value for operation_id, _ in OperationLookup.items() }) + +def uri_decode(value): + \\"\\"\\" + URI decode a value or list of values + \\"\\"\\" + if isinstance(value, list): + return [urllib.parse.unquote(v) for v in value] + return urllib.parse.unquote(value) + +def decode_request_parameters(parameters): + \\"\\"\\" + URI decode api request parameters (path, query or multi-value query) + \\"\\"\\" + return { key: uri_decode(parameters[key]) if parameters[key] is not None else parameters[key] for key in parameters.keys() } + +def parse_body(body, content_types, model): + \\"\\"\\" + Parse the body of an api request into the given model if present + \\"\\"\\" + if len([c for c in content_types if c != 'application/json']) == 0: + body = json.loads(body or '{}') + if model != Any: + body = model(**body) + return body + + +RequestParameters = TypeVar('RequestParameters') +RequestArrayParameters = TypeVar('RequestArrayParameters') +RequestBody = TypeVar('RequestBody') +ResponseBody = TypeVar('ResponseBody') +StatusCode = TypeVar('StatusCode') + +@dataclass +class ApiRequest(Generic[RequestParameters, RequestArrayParameters, RequestBody]): + request_parameters: RequestParameters + request_array_parameters: RequestArrayParameters + body: RequestBody + event: Any + context: Any + interceptor_context: Dict[str, Any] + +@dataclass +class ChainedApiRequest(ApiRequest[RequestParameters, RequestArrayParameters, RequestBody], + Generic[RequestParameters, RequestArrayParameters, RequestBody]): + + chain: 'HandlerChain' + +@dataclass +class ApiResponse(Generic[StatusCode, ResponseBody]): + status_code: StatusCode + headers: Dict[str, str] + body: ResponseBody + +class HandlerChain(Generic[RequestParameters, RequestArrayParameters, RequestBody, StatusCode, ResponseBody]): + def next(self, request: ChainedApiRequest[RequestParameters, RequestArrayParameters, RequestBody]) -> ApiResponse[StatusCode, ResponseBody]: + raise Exception(\\"Not implemented!\\") + +def _build_handler_chain(_interceptors, handler) -> HandlerChain: + if len(_interceptors) == 0: + class BaseHandlerChain(HandlerChain[RequestParameters, RequestArrayParameters, RequestBody, StatusCode, ResponseBody]): + def next(self, request: ApiRequest[RequestParameters, RequestArrayParameters, RequestBody]) -> ApiResponse[StatusCode, ResponseBody]: + return handler(request) + return BaseHandlerChain() + else: + interceptor = _interceptors[0] + + class RemainingHandlerChain(HandlerChain[RequestParameters, RequestArrayParameters, RequestBody, StatusCode, ResponseBody]): + def next(self, request: ChainedApiRequest[RequestParameters, RequestArrayParameters, RequestBody]) -> ApiResponse[StatusCode, ResponseBody]: + return interceptor(ChainedApiRequest( + request_parameters = request.request_parameters, + request_array_parameters = request.request_array_parameters, + body = request.body, + event = request.event, + context = request.context, + interceptor_context = request.interceptor_context, + chain = _build_handler_chain(_interceptors[1:len(_interceptors)], handler), + )) + return RemainingHandlerChain() + + +# Request parameters are single value query params or path params +class NeitherRequestParameters(TypedDict): + ... + +# Request array parameters are multi-value query params +class NeitherRequestArrayParameters(TypedDict): + ... + +# Request body type (default to Any when no body parameters exist, or leave unchanged as str if it's a primitive type) +NeitherRequestBody = Any + +Neither200OperationResponse = ApiResponse[Literal[200], None] +NeitherOperationResponses = Union[Neither200OperationResponse, ] + +# Request type for neither +NeitherRequest = ApiRequest[NeitherRequestParameters, NeitherRequestArrayParameters, NeitherRequestBody] +NeitherChainedRequest = ChainedApiRequest[NeitherRequestParameters, NeitherRequestArrayParameters, NeitherRequestBody] + +class NeitherHandlerFunction(Protocol): + def __call__(self, input: NeitherRequest, **kwargs) -> NeitherOperationResponses: + ... + +NeitherInterceptor = Callable[[NeitherChainedRequest], NeitherOperationResponses] + +def neither_handler(_handler: NeitherHandlerFunction = None, interceptors: List[NeitherInterceptor] = []): + \\"\\"\\" + Decorator for an api handler for the neither operation, providing a typed interface for inputs and outputs + \\"\\"\\" + def _handler_wrapper(handler: NeitherHandlerFunction): + @wraps(handler) + def wrapper(event, context, additional_interceptors = [], **kwargs): + request_parameters = decode_request_parameters({ + **(event['pathParameters'] or {}), + **(event['queryStringParameters'] or {}), + }) + request_array_parameters = decode_request_parameters({ + **(event['multiValueQueryStringParameters'] or {}), + }) + body = {} + interceptor_context = {} + + chain = _build_handler_chain(additional_interceptors + interceptors, handler) + response = chain.next(ApiRequest( + request_parameters, + request_array_parameters, + body, + event, + context, + interceptor_context, + ), **kwargs) + + response_body = '' + if response.body is None: + pass + elif response.status_code == 200: + response_body = response.body + + return { + 'statusCode': response.status_code, + 'headers': response.headers, + 'body': response_body, + } + return wrapper + + # Support use as a decorator with no arguments, or with interceptor arguments + if callable(_handler): + return _handler_wrapper(_handler) + elif _handler is None: + return _handler_wrapper + else: + raise Exception(\\"Positional arguments are not supported by neither_handler.\\") + +# Request parameters are single value query params or path params +class BothRequestParameters(TypedDict): + ... + +# Request array parameters are multi-value query params +class BothRequestArrayParameters(TypedDict): + ... + +# Request body type (default to Any when no body parameters exist, or leave unchanged as str if it's a primitive type) +BothRequestBody = Any + +Both200OperationResponse = ApiResponse[Literal[200], None] +BothOperationResponses = Union[Both200OperationResponse, ] + +# Request type for both +BothRequest = ApiRequest[BothRequestParameters, BothRequestArrayParameters, BothRequestBody] +BothChainedRequest = ChainedApiRequest[BothRequestParameters, BothRequestArrayParameters, BothRequestBody] + +class BothHandlerFunction(Protocol): + def __call__(self, input: BothRequest, **kwargs) -> BothOperationResponses: + ... + +BothInterceptor = Callable[[BothChainedRequest], BothOperationResponses] + +def both_handler(_handler: BothHandlerFunction = None, interceptors: List[BothInterceptor] = []): + \\"\\"\\" + Decorator for an api handler for the both operation, providing a typed interface for inputs and outputs + \\"\\"\\" + def _handler_wrapper(handler: BothHandlerFunction): + @wraps(handler) + def wrapper(event, context, additional_interceptors = [], **kwargs): + request_parameters = decode_request_parameters({ + **(event['pathParameters'] or {}), + **(event['queryStringParameters'] or {}), + }) + request_array_parameters = decode_request_parameters({ + **(event['multiValueQueryStringParameters'] or {}), + }) + body = {} + interceptor_context = {} + + chain = _build_handler_chain(additional_interceptors + interceptors, handler) + response = chain.next(ApiRequest( + request_parameters, + request_array_parameters, + body, + event, + context, + interceptor_context, + ), **kwargs) + + response_body = '' + if response.body is None: + pass + elif response.status_code == 200: + response_body = response.body + + return { + 'statusCode': response.status_code, + 'headers': response.headers, + 'body': response_body, + } + return wrapper + + # Support use as a decorator with no arguments, or with interceptor arguments + if callable(_handler): + return _handler_wrapper(_handler) + elif _handler is None: + return _handler_wrapper + else: + raise Exception(\\"Positional arguments are not supported by both_handler.\\") + +# Request parameters are single value query params or path params +class Tag1RequestParameters(TypedDict): + ... + +# Request array parameters are multi-value query params +class Tag1RequestArrayParameters(TypedDict): + ... + +# Request body type (default to Any when no body parameters exist, or leave unchanged as str if it's a primitive type) +Tag1RequestBody = Any + +Tag1200OperationResponse = ApiResponse[Literal[200], None] +Tag1OperationResponses = Union[Tag1200OperationResponse, ] + +# Request type for tag1 +Tag1Request = ApiRequest[Tag1RequestParameters, Tag1RequestArrayParameters, Tag1RequestBody] +Tag1ChainedRequest = ChainedApiRequest[Tag1RequestParameters, Tag1RequestArrayParameters, Tag1RequestBody] + +class Tag1HandlerFunction(Protocol): + def __call__(self, input: Tag1Request, **kwargs) -> Tag1OperationResponses: + ... + +Tag1Interceptor = Callable[[Tag1ChainedRequest], Tag1OperationResponses] + +def tag1_handler(_handler: Tag1HandlerFunction = None, interceptors: List[Tag1Interceptor] = []): + \\"\\"\\" + Decorator for an api handler for the tag1 operation, providing a typed interface for inputs and outputs + \\"\\"\\" + def _handler_wrapper(handler: Tag1HandlerFunction): + @wraps(handler) + def wrapper(event, context, additional_interceptors = [], **kwargs): + request_parameters = decode_request_parameters({ + **(event['pathParameters'] or {}), + **(event['queryStringParameters'] or {}), + }) + request_array_parameters = decode_request_parameters({ + **(event['multiValueQueryStringParameters'] or {}), + }) + body = {} + interceptor_context = {} + + chain = _build_handler_chain(additional_interceptors + interceptors, handler) + response = chain.next(ApiRequest( + request_parameters, + request_array_parameters, + body, + event, + context, + interceptor_context, + ), **kwargs) + + response_body = '' + if response.body is None: + pass + elif response.status_code == 200: + response_body = response.body + + return { + 'statusCode': response.status_code, + 'headers': response.headers, + 'body': response_body, + } + return wrapper + + # Support use as a decorator with no arguments, or with interceptor arguments + if callable(_handler): + return _handler_wrapper(_handler) + elif _handler is None: + return _handler_wrapper + else: + raise Exception(\\"Positional arguments are not supported by tag1_handler.\\") + +# Request parameters are single value query params or path params +class Tag2RequestParameters(TypedDict): + ... + +# Request array parameters are multi-value query params +class Tag2RequestArrayParameters(TypedDict): + ... + +# Request body type (default to Any when no body parameters exist, or leave unchanged as str if it's a primitive type) +Tag2RequestBody = Any + +Tag2200OperationResponse = ApiResponse[Literal[200], None] +Tag2OperationResponses = Union[Tag2200OperationResponse, ] + +# Request type for tag2 +Tag2Request = ApiRequest[Tag2RequestParameters, Tag2RequestArrayParameters, Tag2RequestBody] +Tag2ChainedRequest = ChainedApiRequest[Tag2RequestParameters, Tag2RequestArrayParameters, Tag2RequestBody] + +class Tag2HandlerFunction(Protocol): + def __call__(self, input: Tag2Request, **kwargs) -> Tag2OperationResponses: + ... + +Tag2Interceptor = Callable[[Tag2ChainedRequest], Tag2OperationResponses] + +def tag2_handler(_handler: Tag2HandlerFunction = None, interceptors: List[Tag2Interceptor] = []): + \\"\\"\\" + Decorator for an api handler for the tag2 operation, providing a typed interface for inputs and outputs + \\"\\"\\" + def _handler_wrapper(handler: Tag2HandlerFunction): + @wraps(handler) + def wrapper(event, context, additional_interceptors = [], **kwargs): + request_parameters = decode_request_parameters({ + **(event['pathParameters'] or {}), + **(event['queryStringParameters'] or {}), + }) + request_array_parameters = decode_request_parameters({ + **(event['multiValueQueryStringParameters'] or {}), + }) + body = {} + interceptor_context = {} + + chain = _build_handler_chain(additional_interceptors + interceptors, handler) + response = chain.next(ApiRequest( + request_parameters, + request_array_parameters, + body, + event, + context, + interceptor_context, + ), **kwargs) + + response_body = '' + if response.body is None: + pass + elif response.status_code == 200: + response_body = response.body + + return { + 'statusCode': response.status_code, + 'headers': response.headers, + 'body': response_body, + } + return wrapper + + # Support use as a decorator with no arguments, or with interceptor arguments + if callable(_handler): + return _handler_wrapper(_handler) + elif _handler is None: + return _handler_wrapper + else: + raise Exception(\\"Positional arguments are not supported by tag2_handler.\\") + +Interceptor = Callable[[ChainedApiRequest[RequestParameters, RequestArrayParameters, RequestBody]], ApiResponse[StatusCode, ResponseBody]] + +def concat_method_and_path(method: str, path: str): + return \\"{}||{}\\".format(method.lower(), path) + +OperationIdByMethodAndPath = { concat_method_and_path(method_and_path[\\"method\\"], method_and_path[\\"path\\"]): operation for operation, method_and_path in OperationLookup.items() } + +@dataclass +class HandlerRouterHandlers: + neither: Callable[[Dict, Any], Dict] + both: Callable[[Dict, Any], Dict] + tag1: Callable[[Dict, Any], Dict] + tag2: Callable[[Dict, Any], Dict] + +def handler_router(handlers: HandlerRouterHandlers, interceptors: List[Interceptor] = []): + \\"\\"\\" + Returns a lambda handler which can be used to route requests to the appropriate typed lambda handler function. + \\"\\"\\" + _handlers = { field.name: getattr(handlers, field.name) for field in fields(handlers) } + + def handler_wrapper(event, context): + operation_id = OperationIdByMethodAndPath[concat_method_and_path(event['requestContext']['httpMethod'], event['requestContext']['resourcePath'])] + handler = _handlers[operation_id] + return handler(event, context, additional_interceptors=interceptors) + return handler_wrapper +", + "test/apis/tags/tag1_api.py": "# coding: utf-8 + +\\"\\"\\" + Multiple Tags Test + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from test.paths.both.get import Both +from test.paths.tag1.get import Tag1 + + +class Tag1Api( + Both, + Tag1, +): + \\"\\"\\"NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + \\"\\"\\" + pass +", + "test/apis/tags/tag2_api.py": "# coding: utf-8 + +\\"\\"\\" + Multiple Tags Test + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from test.paths.tag2.get import Tag2 + + +class Tag2Api( + Tag2, +): + \\"\\"\\"NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + \\"\\"\\" + pass +", + "test/configuration.py": "# coding: utf-8 + +\\"\\"\\" + Multiple Tags Test + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +\\"\\"\\" + +import copy +import logging +import multiprocessing +import sys +import urllib3 + +from http import client as http_client +from test.exceptions import ApiValueError + + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems', + 'uniqueItems', 'maxProperties', 'minProperties', +} + +class Configuration(object): + \\"\\"\\"NOTE: This class is auto generated by OpenAPI Generator + + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param host: Base url + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. + :param disabled_client_side_validations (string): Comma-separated list of + JSON schema validation keywords to disable JSON schema structural validation + rules. The following keywords may be specified: multipleOf, maximum, + exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, + maxItems, minItems. + By default, the validation is performed for data generated locally by the client + and data received from the server, independent of any validation performed by + the server side. If the input data does not satisfy the JSON schema validation + rules specified in the OpenAPI document, an exception is raised. + If disabled_client_side_validations is set, structural validation is + disabled. This can be useful to troubleshoot data validation problem, such as + when the OpenAPI document validation rules do not match the actual API data + received by the server. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum values before. + + \\"\\"\\" + + _default = None + + def __init__( + self, + host=None, + discard_unknown_keys=False, + disabled_client_side_validations=\\"\\", + server_index=None, + server_variables=None, + server_operation_index=None, + server_operation_variables=None, + ): + \\"\\"\\"Constructor + \\"\\"\\" + self._base_path = \\"http://localhost\\" if host is None else host + \\"\\"\\"Default Base url + \\"\\"\\" + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + \\"\\"\\"Default server index + \\"\\"\\" + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + \\"\\"\\"Default server variables + \\"\\"\\" + self.temp_folder_path = None + \\"\\"\\"Temp file folder for downloading files + \\"\\"\\" + # Authentication Settings + self.disabled_client_side_validations = disabled_client_side_validations + self.logger = {} + \\"\\"\\"Logging Settings + \\"\\"\\" + self.logger[\\"package_logger\\"] = logging.getLogger(\\"test\\") + self.logger[\\"urllib3_logger\\"] = logging.getLogger(\\"urllib3\\") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + \\"\\"\\"Log format + \\"\\"\\" + self.logger_stream_handler = None + \\"\\"\\"Log stream handler + \\"\\"\\" + self.logger_file_handler = None + \\"\\"\\"Log file handler + \\"\\"\\" + self.logger_file = None + \\"\\"\\"Debug file location + \\"\\"\\" + self.debug = False + \\"\\"\\"Debug switch + \\"\\"\\" + + self.verify_ssl = True + \\"\\"\\"SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + \\"\\"\\" + self.ssl_ca_cert = None + \\"\\"\\"Set this to customize the certificate file to verify the peer. + \\"\\"\\" + self.cert_file = None + \\"\\"\\"client certificate file + \\"\\"\\" + self.key_file = None + \\"\\"\\"client key file + \\"\\"\\" + self.assert_hostname = None + \\"\\"\\"Set this to True/False to enable/disable SSL hostname verification. + \\"\\"\\" + + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + \\"\\"\\"urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + \\"\\"\\" + + self.proxy = None + \\"\\"\\"Proxy URL + \\"\\"\\" + self.proxy_headers = None + \\"\\"\\"Proxy headers + \\"\\"\\" + self.safe_chars_for_path_param = '' + \\"\\"\\"Safe chars for path_param + \\"\\"\\" + self.retries = None + \\"\\"\\"Adding retries to override urllib3 default value 3 + \\"\\"\\" + # Enable client side validation + self.client_side_validation = True + + # Options to pass down to the underlying urllib3 socket + self.socket_options = None + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + if name == 'disabled_client_side_validations': + s = set(filter(None, value.split(','))) + for v in s: + if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: + raise ApiValueError( + \\"Invalid keyword: '{0}''\\".format(v)) + self._disabled_client_side_validations = s + + @classmethod + def set_default(cls, default): + \\"\\"\\"Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + \\"\\"\\" + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + \\"\\"\\"Return new instance of configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + \\"\\"\\" + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() + + @property + def logger_file(self): + \\"\\"\\"The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + \\"\\"\\" + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + \\"\\"\\"The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + \\"\\"\\" + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + \\"\\"\\"Debug status + + :param value: The debug status, True or False. + :type: bool + \\"\\"\\" + return self.__debug + + @debug.setter + def debug(self, value): + \\"\\"\\"Debug status + + :param value: The debug status, True or False. + :type: bool + \\"\\"\\" + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on http_client debug + http_client.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default \`logging.WARNING\` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off http_client debug + http_client.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + \\"\\"\\"The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + \\"\\"\\" + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + \\"\\"\\"The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + \\"\\"\\" + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + \\"\\"\\"Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + \\"\\"\\" + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return \\"%s %s\\" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + \\"\\"\\"Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + \\"\\"\\" + username = \\"\\" + if self.username is not None: + username = self.username + password = \\"\\" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + \\"\\"\\"Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + \\"\\"\\" + auth = {} + return auth + + def to_debug_report(self): + \\"\\"\\"Gets the essential information for debugging. + + :return: The report for debugging. + \\"\\"\\" + return \\"Python SDK Debug Report:\\\\n\\"\\\\ + \\"OS: {env}\\\\n\\"\\\\ + \\"Python Version: {pyversion}\\\\n\\"\\\\ + \\"Version of the API: 1.0.0\\\\n\\"\\\\ + \\"SDK Package Version: 1.0.0\\".\\\\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + \\"\\"\\"Gets an array of host settings + + :return: An array of host settings + \\"\\"\\" + return [ + { + 'url': \\"\\", + 'description': \\"No description provided\\", + } + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + \\"\\"\\"Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + \\"\\"\\" + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + \\"Invalid index {0} when selecting the host settings. \\" + \\"Must be less than {1}\\".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \\\\ + and used_value not in variable['enum_values']: + raise ValueError( + \\"The variable \`{0}\` in the host URL has invalid value \\" + \\"{1}. Must be {2}.\\".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace(\\"{\\" + variable_name + \\"}\\", used_value) + + return url + + @property + def host(self): + \\"\\"\\"Return generated host.\\"\\"\\" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + \\"\\"\\"Fix base path.\\"\\"\\" + self._base_path = value + self.server_index = None +", + "test/example.py": "def hello(name: str) -> str: + \\"\\"\\"A simple greeting. + Args: + name (str): Name to greet. + Returns: + str: greeting message + \\"\\"\\" + return f\\"Hello {name}!\\" +", + "test/exceptions.py": "# coding: utf-8 + +\\"\\"\\" + Multiple Tags Test + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +\\"\\"\\" +import dataclasses +import typing + +from urllib3._collections import HTTPHeaderDict + + +class OpenApiException(Exception): + \\"\\"\\"The base exception class for all OpenAPIExceptions\\"\\"\\" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + \\"\\"\\" Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + \\"\\"\\" + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = \\"{0} at {1}\\".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None): + \\"\\"\\" + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + \\"\\"\\" + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = \\"{0} at {1}\\".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiAttributeError(OpenApiException, AttributeError): + def __init__(self, msg, path_to_item=None): + \\"\\"\\" + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + \\"\\"\\" + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = \\"{0} at {1}\\".format(msg, render_path(path_to_item)) + super(ApiAttributeError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None): + \\"\\"\\" + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + \\"\\"\\" + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = \\"{0} at {1}\\".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +T = typing.TypeVar(\\"T\\") + + +@dataclasses.dataclass +class ApiException(OpenApiException, typing.Generic[T]): + status: int + reason: str + api_response: typing.Optional[T] = None + + @property + def body(self) -> typing.Union[str, bytes, None]: + if not self.api_response: + return None + return self.api_response.response.data + + @property + def headers(self) -> typing.Optional[HTTPHeaderDict]: + if not self.api_response: + return None + return self.api_response.response.getheaders() + + def __str__(self): + \\"\\"\\"Custom error messages for exception\\"\\"\\" + error_message = \\"({0})\\\\n\\"\\\\ + \\"Reason: {1}\\\\n\\".format(self.status, self.reason) + if self.headers: + error_message += \\"HTTP response headers: {0}\\\\n\\".format( + self.headers) + + if self.body: + error_message += \\"HTTP response body: {0}\\\\n\\".format(self.body) + + return error_message + + +def render_path(path_to_item): + \\"\\"\\"Returns a string representation of a path\\"\\"\\" + result = \\"\\" + for pth in path_to_item: + if isinstance(pth, int): + result += \\"[{0}]\\".format(pth) + else: + result += \\"['{0}']\\".format(pth) + return result +", + "test/model/__init__.py": "# we can not import model classes here because that would create a circular +# reference which would not work in python2 +# do not import all models into this module because that uses a lot of memory and stack frames +# if you need the ability to import all models from one package, import them with +# from test.models import ModelA, ModelB +", + "test/models/__init__.py": "# coding: utf-8 + +# flake8: noqa + +# import all models into this package +# if you have many models here with many references from one model to another this may +# raise a RecursionError +# to avoid this, import only the models that you directly need like: +# from test.model.pet import Pet +# or import this package, but before doing it, use: +# import sys +# sys.setrecursionlimit(n) + +", + "test/paths/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames +# if you need the ability to import all endpoints from this module, import them with +# from test.apis.path_to_api import path_to_api + +import enum + + +class PathValues(str, enum.Enum): + TAG1 = \\"/tag1\\" + TAG2 = \\"/tag2\\" + BOTH = \\"/both\\" + NEITHER = \\"/neither\\" +", + "test/paths/both/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames +# if you need the ability to import all endpoints from this module, import them with +# from test.paths.both import Api + +from test.paths import PathValues + +path = PathValues.BOTH", + "test/paths/both/get.py": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from dataclasses import dataclass +import typing_extensions +import urllib3 + +from test import api_client, exceptions +from datetime import date, datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from test import schemas # noqa: F401 + +from . import path + + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) +_status_code_to_response = { + '200': _response_for_200, +} + + +class BaseApi(api_client.Api): + @typing.overload + def _both_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _both_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _both_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _both_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + \\"\\"\\" + :param skip_deserialization: If true then api_response.response will be set but + api_response.body and api_response.headers will not be deserialized into schema + class instances + \\"\\"\\" + used_path = path.value + # TODO add cookie handling + + response = self.api_client.call_api( + resource_path=used_path, + method='get'.upper(), + stream=stream, + timeout=timeout, + ) + + if skip_deserialization: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + else: + response_for_status = _status_code_to_response.get(str(response.status)) + if response_for_status: + api_response = response_for_status.deserialize(response, self.api_client.configuration) + else: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + + if not 200 <= response.status <= 299: + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) + + return api_response + + +class Both(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + @typing.overload + def both( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def both( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def both( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def both( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._both_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForget(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._both_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +", + "test/paths/both/get.pyi": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from dataclasses import dataclass +import typing_extensions +import urllib3 + +from test import api_client, exceptions +from datetime import date, datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from test import schemas # noqa: F401 + + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) + + +class BaseApi(api_client.Api): + @typing.overload + def _both_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _both_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _both_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _both_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + \\"\\"\\" + :param skip_deserialization: If true then api_response.response will be set but + api_response.body and api_response.headers will not be deserialized into schema + class instances + \\"\\"\\" + used_path = path.value + # TODO add cookie handling + + response = self.api_client.call_api( + resource_path=used_path, + method='get'.upper(), + stream=stream, + timeout=timeout, + ) + + if skip_deserialization: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + else: + response_for_status = _status_code_to_response.get(str(response.status)) + if response_for_status: + api_response = response_for_status.deserialize(response, self.api_client.configuration) + else: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + + if not 200 <= response.status <= 299: + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) + + return api_response + + +class Both(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + @typing.overload + def both( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def both( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def both( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def both( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._both_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForget(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._both_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +", + "test/paths/neither/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames +# if you need the ability to import all endpoints from this module, import them with +# from test.paths.neither import Api + +from test.paths import PathValues + +path = PathValues.NEITHER", + "test/paths/neither/get.py": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from dataclasses import dataclass +import typing_extensions +import urllib3 + +from test import api_client, exceptions +from datetime import date, datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from test import schemas # noqa: F401 + +from . import path + + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) +_status_code_to_response = { + '200': _response_for_200, +} + + +class BaseApi(api_client.Api): + @typing.overload + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _neither_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + \\"\\"\\" + :param skip_deserialization: If true then api_response.response will be set but + api_response.body and api_response.headers will not be deserialized into schema + class instances + \\"\\"\\" + used_path = path.value + # TODO add cookie handling + + response = self.api_client.call_api( + resource_path=used_path, + method='get'.upper(), + stream=stream, + timeout=timeout, + ) + + if skip_deserialization: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + else: + response_for_status = _status_code_to_response.get(str(response.status)) + if response_for_status: + api_response = response_for_status.deserialize(response, self.api_client.configuration) + else: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + + if not 200 <= response.status <= 299: + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) + + return api_response + + +class Neither(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + @typing.overload + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def neither( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._neither_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForget(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._neither_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +", + "test/paths/neither/get.pyi": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from dataclasses import dataclass +import typing_extensions +import urllib3 + +from test import api_client, exceptions +from datetime import date, datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from test import schemas # noqa: F401 + + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) + + +class BaseApi(api_client.Api): + @typing.overload + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _neither_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + \\"\\"\\" + :param skip_deserialization: If true then api_response.response will be set but + api_response.body and api_response.headers will not be deserialized into schema + class instances + \\"\\"\\" + used_path = path.value + # TODO add cookie handling + + response = self.api_client.call_api( + resource_path=used_path, + method='get'.upper(), + stream=stream, + timeout=timeout, + ) + + if skip_deserialization: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + else: + response_for_status = _status_code_to_response.get(str(response.status)) + if response_for_status: + api_response = response_for_status.deserialize(response, self.api_client.configuration) + else: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + + if not 200 <= response.status <= 299: + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) + + return api_response + + +class Neither(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + @typing.overload + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def neither( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._neither_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForget(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._neither_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +", + "test/paths/tag1/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames +# if you need the ability to import all endpoints from this module, import them with +# from test.paths.tag1 import Api + +from test.paths import PathValues + +path = PathValues.TAG1", + "test/paths/tag1/get.py": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from dataclasses import dataclass +import typing_extensions +import urllib3 + +from test import api_client, exceptions +from datetime import date, datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from test import schemas # noqa: F401 + +from . import path + + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) +_status_code_to_response = { + '200': _response_for_200, +} + + +class BaseApi(api_client.Api): + @typing.overload + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _tag1_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + \\"\\"\\" + :param skip_deserialization: If true then api_response.response will be set but + api_response.body and api_response.headers will not be deserialized into schema + class instances + \\"\\"\\" + used_path = path.value + # TODO add cookie handling + + response = self.api_client.call_api( + resource_path=used_path, + method='get'.upper(), + stream=stream, + timeout=timeout, + ) + + if skip_deserialization: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + else: + response_for_status = _status_code_to_response.get(str(response.status)) + if response_for_status: + api_response = response_for_status.deserialize(response, self.api_client.configuration) + else: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + + if not 200 <= response.status <= 299: + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) + + return api_response + + +class Tag1(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + @typing.overload + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def tag1( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._tag1_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForget(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._tag1_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +", + "test/paths/tag1/get.pyi": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from dataclasses import dataclass +import typing_extensions +import urllib3 + +from test import api_client, exceptions +from datetime import date, datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from test import schemas # noqa: F401 + + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) + + +class BaseApi(api_client.Api): + @typing.overload + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _tag1_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + \\"\\"\\" + :param skip_deserialization: If true then api_response.response will be set but + api_response.body and api_response.headers will not be deserialized into schema + class instances + \\"\\"\\" + used_path = path.value + # TODO add cookie handling + + response = self.api_client.call_api( + resource_path=used_path, + method='get'.upper(), + stream=stream, + timeout=timeout, + ) + + if skip_deserialization: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + else: + response_for_status = _status_code_to_response.get(str(response.status)) + if response_for_status: + api_response = response_for_status.deserialize(response, self.api_client.configuration) + else: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + + if not 200 <= response.status <= 299: + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) + + return api_response + + +class Tag1(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + @typing.overload + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def tag1( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._tag1_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForget(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._tag1_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +", + "test/paths/tag2/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames +# if you need the ability to import all endpoints from this module, import them with +# from test.paths.tag2 import Api + +from test.paths import PathValues + +path = PathValues.TAG2", + "test/paths/tag2/get.py": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from dataclasses import dataclass +import typing_extensions +import urllib3 + +from test import api_client, exceptions +from datetime import date, datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from test import schemas # noqa: F401 + +from . import path + + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) +_status_code_to_response = { + '200': _response_for_200, +} + + +class BaseApi(api_client.Api): + @typing.overload + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _tag2_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + \\"\\"\\" + :param skip_deserialization: If true then api_response.response will be set but + api_response.body and api_response.headers will not be deserialized into schema + class instances + \\"\\"\\" + used_path = path.value + # TODO add cookie handling + + response = self.api_client.call_api( + resource_path=used_path, + method='get'.upper(), + stream=stream, + timeout=timeout, + ) + + if skip_deserialization: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + else: + response_for_status = _status_code_to_response.get(str(response.status)) + if response_for_status: + api_response = response_for_status.deserialize(response, self.api_client.configuration) + else: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + + if not 200 <= response.status <= 299: + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) + + return api_response + + +class Tag2(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + @typing.overload + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def tag2( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._tag2_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForget(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._tag2_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +", + "test/paths/tag2/get.pyi": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from dataclasses import dataclass +import typing_extensions +import urllib3 + +from test import api_client, exceptions +from datetime import date, datetime # noqa: F401 +import decimal # noqa: F401 +import functools # noqa: F401 +import io # noqa: F401 +import re # noqa: F401 +import typing # noqa: F401 +import typing_extensions # noqa: F401 +import uuid # noqa: F401 + +import frozendict # noqa: F401 + +from test import schemas # noqa: F401 + + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) + + +class BaseApi(api_client.Api): + @typing.overload + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _tag2_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + \\"\\"\\" + :param skip_deserialization: If true then api_response.response will be set but + api_response.body and api_response.headers will not be deserialized into schema + class instances + \\"\\"\\" + used_path = path.value + # TODO add cookie handling + + response = self.api_client.call_api( + resource_path=used_path, + method='get'.upper(), + stream=stream, + timeout=timeout, + ) + + if skip_deserialization: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + else: + response_for_status = _status_code_to_response.get(str(response.status)) + if response_for_status: + api_response = response_for_status.deserialize(response, self.api_client.configuration) + else: + api_response = api_client.ApiResponseWithoutDeserialization(response=response) + + if not 200 <= response.status <= 299: + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) + + return api_response + + +class Tag2(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + @typing.overload + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def tag2( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._tag2_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForget(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._tag2_oapg( + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +", + "test/rest.py": "# coding: utf-8 + +\\"\\"\\" + Multiple Tags Test + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +\\"\\"\\" + +import logging +import ssl +from urllib.parse import urlencode +import typing + +import certifi +import urllib3 +from urllib3._collections import HTTPHeaderDict + +from test.exceptions import ApiException, ApiValueError + + +logger = logging.getLogger(__name__) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + # ca_certs + if configuration.ssl_ca_cert: + ca_certs = configuration.ssl_ca_cert + else: + # if not set certificate file, use Mozilla's root certificates. + ca_certs = certifi.where() + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=ca_certs, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + def request( + self, + method: str, + url: str, + headers: typing.Optional[HTTPHeaderDict] = None, + fields: typing.Optional[typing.Tuple[typing.Tuple[str, typing.Any], ...]] = None, + body: typing.Optional[typing.Union[str, bytes]] = None, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> urllib3.HTTPResponse: + \\"\\"\\"Perform requests. + + :param method: http request method + :param url: http request url + :param headers: http request headers + :param body: request body, for other types + :param fields: request parameters for + \`application/x-www-form-urlencoded\` + or \`multipart/form-data\` + :param stream: if True, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is False. + :param timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + \\"\\"\\" + method = method.upper() + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] + + if fields and body: + raise ApiValueError( + \\"body parameter cannot be used with fields parameter.\\" + ) + + fields = fields or {} + headers = headers or {} + + if timeout: + if isinstance(timeout, (int, float)): # noqa: E501,F821 + timeout = urllib3.Timeout(total=timeout) + elif (isinstance(timeout, tuple) and + len(timeout) == 2): + timeout = urllib3.Timeout(connect=timeout[0], read=timeout[1]) + + try: + # For \`POST\`, \`PUT\`, \`PATCH\`, \`OPTIONS\`, \`DELETE\` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if 'Content-Type' not in headers and body is None: + r = self.pool_manager.request( + method, + url, + preload_content=not stream, + timeout=timeout, + headers=headers + ) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + r = self.pool_manager.request( + method, url, + body=body, + fields=fields, + encode_multipart=False, + preload_content=not stream, + timeout=timeout, + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by urllib3 will be + # overwritten. + del headers['Content-Type'] + r = self.pool_manager.request( + method, url, + fields=fields, + encode_multipart=True, + preload_content=not stream, + timeout=timeout, + headers=headers) + # Pass a \`string\` parameter directly in the body to support + # other content types than Json when \`body\` argument is + # provided in serialized form + elif isinstance(body, str) or isinstance(body, bytes): + request_body = body + r = self.pool_manager.request( + method, url, + body=request_body, + preload_content=not stream, + timeout=timeout, + headers=headers) + else: + # Cannot generate the request from given parameters + msg = \\"\\"\\"Cannot prepare a request message for provided + arguments. Please check that your arguments match + declared content type.\\"\\"\\" + raise ApiException(status=0, reason=msg) + # For \`GET\`, \`HEAD\` + else: + r = self.pool_manager.request(method, url, + preload_content=not stream, + timeout=timeout, + headers=headers) + except urllib3.exceptions.SSLError as e: + msg = \\"{0}\\\\n{1}\\".format(type(e).__name__, str(e)) + raise ApiException(status=0, reason=msg) + + if not stream: + # log response body + logger.debug(\\"response body: %s\\", r.data) + + return r + + def GET(self, url, headers=None, stream=False, + timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request(\\"GET\\", url, + headers=headers, + stream=stream, + timeout=timeout, + fields=fields) + + def HEAD(self, url, headers=None, stream=False, + timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request(\\"HEAD\\", url, + headers=headers, + stream=stream, + timeout=timeout, + fields=fields) + + def OPTIONS(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request(\\"OPTIONS\\", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def DELETE(self, url, headers=None, body=None, + stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request(\\"DELETE\\", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def POST(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request(\\"POST\\", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def PUT(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request(\\"PUT\\", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) + + def PATCH(self, url, headers=None, + body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse: + return self.request(\\"PATCH\\", url, + headers=headers, + stream=stream, + timeout=timeout, + body=body, fields=fields) +", + "test/schemas.py": "# coding: utf-8 + +\\"\\"\\" + Multiple Tags Test + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +\\"\\"\\" + +from collections import defaultdict +from datetime import date, datetime, timedelta # noqa: F401 +import functools +import decimal +import io +import re +import types +import typing +import uuid + +from dateutil.parser.isoparser import isoparser, _takes_ascii +import frozendict + +from test.exceptions import ( + ApiTypeError, + ApiValueError, +) +from test.configuration import ( + Configuration, +) + + +class Unset(object): + \\"\\"\\" + An instance of this class is set as the default value for object type(dict) properties that are optional + When a property has an unset value, that property will not be assigned in the dict + \\"\\"\\" + pass + +unset = Unset() + +none_type = type(None) +file_type = io.IOBase + + +class FileIO(io.FileIO): + \\"\\"\\" + A class for storing files + Note: this class is not immutable + \\"\\"\\" + + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader]): + if isinstance(_arg, (io.FileIO, io.BufferedReader)): + if _arg.closed: + raise ApiValueError('Invalid file state; file is closed and must be open') + _arg.close() + inst = super(FileIO, cls).__new__(cls, _arg.name) + super(FileIO, inst).__init__(_arg.name) + return inst + raise ApiValueError('FileIO must be passed _arg which contains the open file') + + def __init__(self, _arg: typing.Union[io.FileIO, io.BufferedReader]): + pass + + +def update(d: dict, u: dict): + \\"\\"\\" + Adds u to d + Where each dict is defaultdict(set) + \\"\\"\\" + if not u: + return d + for k, v in u.items(): + if k not in d: + d[k] = v + else: + d[k] = d[k] | v + + +class ValidationMetadata(frozendict.frozendict): + \\"\\"\\" + A class storing metadata that is needed to validate OpenApi Schema payloads + \\"\\"\\" + def __new__( + cls, + path_to_item: typing.Tuple[typing.Union[str, int], ...] = tuple(['args[0]']), + from_server: bool = False, + configuration: typing.Optional[Configuration] = None, + seen_classes: typing.FrozenSet[typing.Type] = frozenset(), + validated_path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Type]] = frozendict.frozendict() + ): + \\"\\"\\" + Args: + path_to_item: the path to the current data being instantiated. + For {'a': [1]} if the code is handling, 1, then the path is ('args[0]', 'a', 0) + This changes from location to location + from_server: whether or not this data came form the server + True when receiving server data + False when instantiating model with client side data not form the server + This does not change from location to location + configuration: the Configuration instance to use + This is needed because in Configuration: + - one can disable validation checking + This does not change from location to location + seen_classes: when deserializing data that matches multiple schemas, this is used to store + the schemas that have been traversed. This is used to stop processing when a cycle is seen. + This changes from location to location + validated_path_to_schemas: stores the already validated schema classes for a given path location + This does not change from location to location + \\"\\"\\" + return super().__new__( + cls, + path_to_item=path_to_item, + from_server=from_server, + configuration=configuration, + seen_classes=seen_classes, + validated_path_to_schemas=validated_path_to_schemas + ) + + def validation_ran_earlier(self, cls: type) -> bool: + validated_schemas = self.validated_path_to_schemas.get(self.path_to_item, set()) + validation_ran_earlier = validated_schemas and cls in validated_schemas + if validation_ran_earlier: + return True + if cls in self.seen_classes: + return True + return False + + @property + def path_to_item(self) -> typing.Tuple[typing.Union[str, int], ...]: + return self.get('path_to_item') + + @property + def from_server(self) -> bool: + return self.get('from_server') + + @property + def configuration(self) -> typing.Optional[Configuration]: + return self.get('configuration') + + @property + def seen_classes(self) -> typing.FrozenSet[typing.Type]: + return self.get('seen_classes') + + @property + def validated_path_to_schemas(self) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Type]]: + return self.get('validated_path_to_schemas') + + +def add_deeper_validated_schemas(validation_metadata: ValidationMetadata, path_to_schemas: dict): + # this is called if validation_ran_earlier and current and deeper locations need to be added + current_path_to_item = validation_metadata.path_to_item + other_path_to_schemas = {} + for path_to_item, schemas in validation_metadata.validated_path_to_schemas.items(): + if len(path_to_item) < len(current_path_to_item): + continue + path_begins_with_current_path = path_to_item[:len(current_path_to_item)] == current_path_to_item + if path_begins_with_current_path: + other_path_to_schemas[path_to_item] = schemas + update(path_to_schemas, other_path_to_schemas) + + +class Singleton: + \\"\\"\\" + Enums and singletons are the same + The same instance is returned for a given key of (cls, _arg) + \\"\\"\\" + _instances = {} + + def __new__(cls, _arg: typing.Any, **kwargs): + \\"\\"\\" + cls base classes: BoolClass, NoneClass, str, decimal.Decimal + The 3rd key is used in the tuple below for a corner case where an enum contains integer 1 + However 1.0 can also be ingested into that enum schema because 1.0 == 1 and + Decimal('1.0') == Decimal('1') + But if we omitted the 3rd value in the key, then Decimal('1.0') would be stored as Decimal('1') + and json serializing that instance would be '1' rather than the expected '1.0' + Adding the 3rd value, the str of _arg ensures that 1.0 -> Decimal('1.0') which is serialized as 1.0 + \\"\\"\\" + key = (cls, _arg, str(_arg)) + if key not in cls._instances: + if isinstance(_arg, (none_type, bool, BoolClass, NoneClass)): + inst = super().__new__(cls) + cls._instances[key] = inst + else: + cls._instances[key] = super().__new__(cls, _arg) + return cls._instances[key] + + def __repr__(self): + if isinstance(self, NoneClass): + return f'<{self.__class__.__name__}: None>' + elif isinstance(self, BoolClass): + if bool(self): + return f'<{self.__class__.__name__}: True>' + return f'<{self.__class__.__name__}: False>' + return f'<{self.__class__.__name__}: {super().__repr__()}>' + + +class classproperty: + + def __init__(self, fget): + self.fget = fget + + def __get__(self, owner_self, owner_cls): + return self.fget(owner_cls) + + +class NoneClass(Singleton): + @classproperty + def NONE(cls): + return cls(None) + + def __bool__(self) -> bool: + return False + + +class BoolClass(Singleton): + @classproperty + def TRUE(cls): + return cls(True) + + @classproperty + def FALSE(cls): + return cls(False) + + @functools.lru_cache() + def __bool__(self) -> bool: + for key, instance in self._instances.items(): + if self is instance: + return bool(key[1]) + raise ValueError('Unable to find the boolean value of this instance') + + +class MetaOapgTyped: + exclusive_maximum: typing.Union[int, float] + inclusive_maximum: typing.Union[int, float] + exclusive_minimum: typing.Union[int, float] + inclusive_minimum: typing.Union[int, float] + max_items: int + min_items: int + discriminator: typing.Dict[str, typing.Dict[str, typing.Type['Schema']]] + + + class properties: + # to hold object properties + pass + + additional_properties: typing.Optional[typing.Type['Schema']] + max_properties: int + min_properties: int + all_of: typing.List[typing.Type['Schema']] + one_of: typing.List[typing.Type['Schema']] + any_of: typing.List[typing.Type['Schema']] + not_schema: typing.Type['Schema'] + max_length: int + min_length: int + items: typing.Type['Schema'] + + +class Schema: + \\"\\"\\" + the base class of all swagger/openapi schemas/models + \\"\\"\\" + __inheritable_primitive_types_set = {decimal.Decimal, str, tuple, frozendict.frozendict, FileIO, bytes, BoolClass, NoneClass} + _types: typing.Set[typing.Type] + MetaOapg = MetaOapgTyped + + @staticmethod + def __get_valid_classes_phrase(input_classes): + \\"\\"\\"Returns a string phrase describing what types are allowed\\"\\"\\" + all_classes = list(input_classes) + all_classes = sorted(all_classes, key=lambda cls: cls.__name__) + all_class_names = [cls.__name__ for cls in all_classes] + if len(all_class_names) == 1: + return \\"is {0}\\".format(all_class_names[0]) + return \\"is one of [{0}]\\".format(\\", \\".join(all_class_names)) + + @staticmethod + def _get_class_oapg(item_cls: typing.Union[types.FunctionType, staticmethod, typing.Type['Schema']]) -> typing.Type['Schema']: + if isinstance(item_cls, types.FunctionType): + # referenced schema + return item_cls() + elif isinstance(item_cls, staticmethod): + # referenced schema + return item_cls.__func__() + return item_cls + + @classmethod + def __type_error_message( + cls, var_value=None, var_name=None, valid_classes=None, key_type=None + ): + \\"\\"\\" + Keyword Args: + var_value (any): the variable which has the type_error + var_name (str): the name of the variable which has the typ error + valid_classes (tuple): the accepted classes for current_item's + value + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a tuple + \\"\\"\\" + key_or_value = \\"value\\" + if key_type: + key_or_value = \\"key\\" + valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) + msg = \\"Invalid type. Required {1} type {2} and \\" \\"passed type was {3}\\".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) + return msg + + @classmethod + def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): + error_msg = cls.__type_error_message( + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type, + ) + return ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type, + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: + \\"\\"\\" + Schema _validate_oapg + All keyword validation except for type checking was done in calling stack frames + If those validations passed, the validated classes are collected in path_to_schemas + + Returns: + path_to_schemas: a map of path to schemas + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + \\"\\"\\" + base_class = type(arg) + if base_class not in cls._types: + raise cls.__get_type_error( + arg, + validation_metadata.path_to_item, + cls._types, + key_type=False, + ) + + path_to_schemas = {validation_metadata.path_to_item: set()} + path_to_schemas[validation_metadata.path_to_item].add(cls) + path_to_schemas[validation_metadata.path_to_item].add(base_class) + return path_to_schemas + + @staticmethod + def _process_schema_classes_oapg( + schema_classes: typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]] + ): + \\"\\"\\" + Processes and mutates schema_classes + If a SomeSchema is a subclass of DictSchema then remove DictSchema because it is already included + \\"\\"\\" + if len(schema_classes) < 2: + return + if len(schema_classes) > 2 and UnsetAnyTypeSchema in schema_classes: + schema_classes.remove(UnsetAnyTypeSchema) + x_schema = schema_type_classes & schema_classes + if not x_schema: + return + x_schema = x_schema.pop() + if any(c is not x_schema and issubclass(c, x_schema) for c in schema_classes): + # needed to not have a mro error in get_new_class + schema_classes.remove(x_schema) + + @classmethod + def __get_new_cls( + cls, + arg, + validation_metadata: ValidationMetadata + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']]: + \\"\\"\\" + Make a new dynamic class and return an instance of that class + We are making an instance of cls, but instead of making cls + make a new class, new_cls + which includes dynamic bases including cls + return an instance of that new class + + Dict property + List Item Assignment Use cases: + 1. value is NOT an instance of the required schema class + the value is validated by _validate_oapg + _validate_oapg returns a key value pair + where the key is the path to the item, and the value will be the required manufactured class + made out of the matching schemas + 2. value is an instance of the correct schema type + the value is NOT validated by _validate_oapg, _validate_oapg only checks that the instance is of the correct schema type + for this value, _validate_oapg does NOT return an entry for it in _path_to_schemas + and in list/dict _get_items_oapg,_get_properties_oapg the value will be directly assigned + because value is of the correct type, and validation was run earlier when the instance was created + \\"\\"\\" + _path_to_schemas = {} + if validation_metadata.validation_ran_earlier(cls): + add_deeper_validated_schemas(validation_metadata, _path_to_schemas) + else: + other_path_to_schemas = cls._validate_oapg(arg, validation_metadata=validation_metadata) + update(_path_to_schemas, other_path_to_schemas) + # loop through it make a new class for each entry + # do not modify the returned result because it is cached and we would be modifying the cached value + path_to_schemas = {} + for path, schema_classes in _path_to_schemas.items(): + \\"\\"\\" + Use cases + 1. N number of schema classes + enum + type != bool/None, classes in path_to_schemas: tuple/frozendict.frozendict/str/Decimal/bytes/FileIo + needs Singleton added + 2. N number of schema classes + enum + type == bool/None, classes in path_to_schemas: BoolClass/NoneClass + Singleton already added + 3. N number of schema classes, classes in path_to_schemas: BoolClass/NoneClass/tuple/frozendict.frozendict/str/Decimal/bytes/FileIo + \\"\\"\\" + cls._process_schema_classes_oapg(schema_classes) + enum_schema = any( + issubclass(this_cls, EnumBase) for this_cls in schema_classes) + inheritable_primitive_type = schema_classes.intersection(cls.__inheritable_primitive_types_set) + chosen_schema_classes = schema_classes - inheritable_primitive_type + suffix = tuple(inheritable_primitive_type) + if enum_schema and suffix[0] not in {NoneClass, BoolClass}: + suffix = (Singleton,) + suffix + + used_classes = tuple(sorted(chosen_schema_classes, key=lambda a_cls: a_cls.__name__)) + suffix + mfg_cls = get_new_class(class_name='DynamicSchema', bases=used_classes) + path_to_schemas[path] = mfg_cls + + return path_to_schemas + + @classmethod + def _get_new_instance_without_conversion_oapg( + cls, + arg: typing.Any, + path_to_item: typing.Tuple[typing.Union[str, int], ...], + path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] + ): + # We have a Dynamic class and we are making an instance of it + if issubclass(cls, frozendict.frozendict) and issubclass(cls, DictBase): + properties = cls._get_properties_oapg(arg, path_to_item, path_to_schemas) + return super(Schema, cls).__new__(cls, properties) + elif issubclass(cls, tuple) and issubclass(cls, ListBase): + items = cls._get_items_oapg(arg, path_to_item, path_to_schemas) + return super(Schema, cls).__new__(cls, items) + \\"\\"\\" + str = openapi str, date, and datetime + decimal.Decimal = openapi int and float + FileIO = openapi binary type and the user inputs a file + bytes = openapi binary type and the user inputs bytes + \\"\\"\\" + return super(Schema, cls).__new__(cls, arg) + + @classmethod + def from_openapi_data_oapg( + cls, + arg: typing.Union[ + str, + date, + datetime, + int, + float, + decimal.Decimal, + bool, + None, + 'Schema', + dict, + frozendict.frozendict, + tuple, + list, + io.FileIO, + io.BufferedReader, + bytes + ], + _configuration: typing.Optional[Configuration] + ): + \\"\\"\\" + Schema from_openapi_data_oapg + \\"\\"\\" + from_server = True + validated_path_to_schemas = {} + arg = cast_to_allowed_types(arg, from_server, validated_path_to_schemas) + validation_metadata = ValidationMetadata( + from_server=from_server, configuration=_configuration, validated_path_to_schemas=validated_path_to_schemas) + path_to_schemas = cls.__get_new_cls(arg, validation_metadata) + new_cls = path_to_schemas[validation_metadata.path_to_item] + new_inst = new_cls._get_new_instance_without_conversion_oapg( + arg, + validation_metadata.path_to_item, + path_to_schemas + ) + return new_inst + + @staticmethod + def __get_input_dict(*args, **kwargs) -> frozendict.frozendict: + input_dict = {} + if args and isinstance(args[0], (dict, frozendict.frozendict)): + input_dict.update(args[0]) + if kwargs: + input_dict.update(kwargs) + return frozendict.frozendict(input_dict) + + @staticmethod + def __remove_unsets(kwargs): + return {key: val for key, val in kwargs.items() if val is not unset} + + def __new__(cls, *_args: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): + \\"\\"\\" + Schema __new__ + + Args: + _args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): the value + kwargs (str, int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): dict values + _configuration: contains the Configuration that enables json schema validation keywords + like minItems, minLength etc + + Note: double underscores are used here because pycharm thinks that these variables + are instance properties if they are named normally :( + \\"\\"\\" + __kwargs = cls.__remove_unsets(kwargs) + if not _args and not __kwargs: + raise TypeError( + 'No input given. args or kwargs must be given.' + ) + if not __kwargs and _args and not isinstance(_args[0], dict): + __arg = _args[0] + else: + __arg = cls.__get_input_dict(*_args, **__kwargs) + __from_server = False + __validated_path_to_schemas = {} + __arg = cast_to_allowed_types( + __arg, __from_server, __validated_path_to_schemas) + __validation_metadata = ValidationMetadata( + configuration=_configuration, from_server=__from_server, validated_path_to_schemas=__validated_path_to_schemas) + __path_to_schemas = cls.__get_new_cls(__arg, __validation_metadata) + __new_cls = __path_to_schemas[__validation_metadata.path_to_item] + return __new_cls._get_new_instance_without_conversion_oapg( + __arg, + __validation_metadata.path_to_item, + __path_to_schemas + ) + + def __init__( + self, + *_args: typing.Union[ + dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Union[ + dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset + ] + ): + \\"\\"\\" + this is needed to fix 'Unexpected argument' warning in pycharm + this code does nothing because all Schema instances are immutable + this means that all input data is passed into and used in new, and after the new instance is made + no new attributes are assigned and init is not used + \\"\\"\\" + pass + +\\"\\"\\" +import itertools +data_types = ('None', 'FrozenDict', 'Tuple', 'Str', 'Decimal', 'Bool') +type_to_cls = { + 'None': 'NoneClass', + 'FrozenDict': 'frozendict.frozendict', + 'Tuple': 'tuple', + 'Str': 'str', + 'Decimal': 'decimal.Decimal', + 'Bool': 'BoolClass' +} +cls_tuples = [v for v in itertools.combinations(data_types, 5)] +typed_classes = [f\\"class {''.join(cls_tuple)}Mixin({', '.join(type_to_cls[typ] for typ in cls_tuple)}):\\\\n pass\\" for cls_tuple in cls_tuples] +for cls in typed_classes: + print(cls) +object_classes = [f\\"{''.join(cls_tuple)}Mixin = object\\" for cls_tuple in cls_tuples] +for cls in object_classes: + print(cls) +\\"\\"\\" +if typing.TYPE_CHECKING: + # qty 1 + NoneMixin = NoneClass + FrozenDictMixin = frozendict.frozendict + TupleMixin = tuple + StrMixin = str + DecimalMixin = decimal.Decimal + BoolMixin = BoolClass + BytesMixin = bytes + FileMixin = FileIO + # qty 2 + class BinaryMixin(bytes, FileIO): + pass + class NoneFrozenDictMixin(NoneClass, frozendict.frozendict): + pass + class NoneTupleMixin(NoneClass, tuple): + pass + class NoneStrMixin(NoneClass, str): + pass + class NoneDecimalMixin(NoneClass, decimal.Decimal): + pass + class NoneBoolMixin(NoneClass, BoolClass): + pass + class FrozenDictTupleMixin(frozendict.frozendict, tuple): + pass + class FrozenDictStrMixin(frozendict.frozendict, str): + pass + class FrozenDictDecimalMixin(frozendict.frozendict, decimal.Decimal): + pass + class FrozenDictBoolMixin(frozendict.frozendict, BoolClass): + pass + class TupleStrMixin(tuple, str): + pass + class TupleDecimalMixin(tuple, decimal.Decimal): + pass + class TupleBoolMixin(tuple, BoolClass): + pass + class StrDecimalMixin(str, decimal.Decimal): + pass + class StrBoolMixin(str, BoolClass): + pass + class DecimalBoolMixin(decimal.Decimal, BoolClass): + pass + # qty 3 + class NoneFrozenDictTupleMixin(NoneClass, frozendict.frozendict, tuple): + pass + class NoneFrozenDictStrMixin(NoneClass, frozendict.frozendict, str): + pass + class NoneFrozenDictDecimalMixin(NoneClass, frozendict.frozendict, decimal.Decimal): + pass + class NoneFrozenDictBoolMixin(NoneClass, frozendict.frozendict, BoolClass): + pass + class NoneTupleStrMixin(NoneClass, tuple, str): + pass + class NoneTupleDecimalMixin(NoneClass, tuple, decimal.Decimal): + pass + class NoneTupleBoolMixin(NoneClass, tuple, BoolClass): + pass + class NoneStrDecimalMixin(NoneClass, str, decimal.Decimal): + pass + class NoneStrBoolMixin(NoneClass, str, BoolClass): + pass + class NoneDecimalBoolMixin(NoneClass, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrMixin(frozendict.frozendict, tuple, str): + pass + class FrozenDictTupleDecimalMixin(frozendict.frozendict, tuple, decimal.Decimal): + pass + class FrozenDictTupleBoolMixin(frozendict.frozendict, tuple, BoolClass): + pass + class FrozenDictStrDecimalMixin(frozendict.frozendict, str, decimal.Decimal): + pass + class FrozenDictStrBoolMixin(frozendict.frozendict, str, BoolClass): + pass + class FrozenDictDecimalBoolMixin(frozendict.frozendict, decimal.Decimal, BoolClass): + pass + class TupleStrDecimalMixin(tuple, str, decimal.Decimal): + pass + class TupleStrBoolMixin(tuple, str, BoolClass): + pass + class TupleDecimalBoolMixin(tuple, decimal.Decimal, BoolClass): + pass + class StrDecimalBoolMixin(str, decimal.Decimal, BoolClass): + pass + # qty 4 + class NoneFrozenDictTupleStrMixin(NoneClass, frozendict.frozendict, tuple, str): + pass + class NoneFrozenDictTupleDecimalMixin(NoneClass, frozendict.frozendict, tuple, decimal.Decimal): + pass + class NoneFrozenDictTupleBoolMixin(NoneClass, frozendict.frozendict, tuple, BoolClass): + pass + class NoneFrozenDictStrDecimalMixin(NoneClass, frozendict.frozendict, str, decimal.Decimal): + pass + class NoneFrozenDictStrBoolMixin(NoneClass, frozendict.frozendict, str, BoolClass): + pass + class NoneFrozenDictDecimalBoolMixin(NoneClass, frozendict.frozendict, decimal.Decimal, BoolClass): + pass + class NoneTupleStrDecimalMixin(NoneClass, tuple, str, decimal.Decimal): + pass + class NoneTupleStrBoolMixin(NoneClass, tuple, str, BoolClass): + pass + class NoneTupleDecimalBoolMixin(NoneClass, tuple, decimal.Decimal, BoolClass): + pass + class NoneStrDecimalBoolMixin(NoneClass, str, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrDecimalMixin(frozendict.frozendict, tuple, str, decimal.Decimal): + pass + class FrozenDictTupleStrBoolMixin(frozendict.frozendict, tuple, str, BoolClass): + pass + class FrozenDictTupleDecimalBoolMixin(frozendict.frozendict, tuple, decimal.Decimal, BoolClass): + pass + class FrozenDictStrDecimalBoolMixin(frozendict.frozendict, str, decimal.Decimal, BoolClass): + pass + class TupleStrDecimalBoolMixin(tuple, str, decimal.Decimal, BoolClass): + pass + # qty 5 + class NoneFrozenDictTupleStrDecimalMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal): + pass + class NoneFrozenDictTupleStrBoolMixin(NoneClass, frozendict.frozendict, tuple, str, BoolClass): + pass + class NoneFrozenDictTupleDecimalBoolMixin(NoneClass, frozendict.frozendict, tuple, decimal.Decimal, BoolClass): + pass + class NoneFrozenDictStrDecimalBoolMixin(NoneClass, frozendict.frozendict, str, decimal.Decimal, BoolClass): + pass + class NoneTupleStrDecimalBoolMixin(NoneClass, tuple, str, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrDecimalBoolMixin(frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass): + pass + # qty 6 + class NoneFrozenDictTupleStrDecimalBoolMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass): + pass + # qty 8 + class NoneFrozenDictTupleStrDecimalBoolFileBytesMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass, FileIO, bytes): + pass +else: + # qty 1 + class NoneMixin: + _types = {NoneClass} + class FrozenDictMixin: + _types = {frozendict.frozendict} + class TupleMixin: + _types = {tuple} + class StrMixin: + _types = {str} + class DecimalMixin: + _types = {decimal.Decimal} + class BoolMixin: + _types = {BoolClass} + class BytesMixin: + _types = {bytes} + class FileMixin: + _types = {FileIO} + # qty 2 + class BinaryMixin: + _types = {bytes, FileIO} + class NoneFrozenDictMixin: + _types = {NoneClass, frozendict.frozendict} + class NoneTupleMixin: + _types = {NoneClass, tuple} + class NoneStrMixin: + _types = {NoneClass, str} + class NoneDecimalMixin: + _types = {NoneClass, decimal.Decimal} + class NoneBoolMixin: + _types = {NoneClass, BoolClass} + class FrozenDictTupleMixin: + _types = {frozendict.frozendict, tuple} + class FrozenDictStrMixin: + _types = {frozendict.frozendict, str} + class FrozenDictDecimalMixin: + _types = {frozendict.frozendict, decimal.Decimal} + class FrozenDictBoolMixin: + _types = {frozendict.frozendict, BoolClass} + class TupleStrMixin: + _types = {tuple, str} + class TupleDecimalMixin: + _types = {tuple, decimal.Decimal} + class TupleBoolMixin: + _types = {tuple, BoolClass} + class StrDecimalMixin: + _types = {str, decimal.Decimal} + class StrBoolMixin: + _types = {str, BoolClass} + class DecimalBoolMixin: + _types = {decimal.Decimal, BoolClass} + # qty 3 + class NoneFrozenDictTupleMixin: + _types = {NoneClass, frozendict.frozendict, tuple} + class NoneFrozenDictStrMixin: + _types = {NoneClass, frozendict.frozendict, str} + class NoneFrozenDictDecimalMixin: + _types = {NoneClass, frozendict.frozendict, decimal.Decimal} + class NoneFrozenDictBoolMixin: + _types = {NoneClass, frozendict.frozendict, BoolClass} + class NoneTupleStrMixin: + _types = {NoneClass, tuple, str} + class NoneTupleDecimalMixin: + _types = {NoneClass, tuple, decimal.Decimal} + class NoneTupleBoolMixin: + _types = {NoneClass, tuple, BoolClass} + class NoneStrDecimalMixin: + _types = {NoneClass, str, decimal.Decimal} + class NoneStrBoolMixin: + _types = {NoneClass, str, BoolClass} + class NoneDecimalBoolMixin: + _types = {NoneClass, decimal.Decimal, BoolClass} + class FrozenDictTupleStrMixin: + _types = {frozendict.frozendict, tuple, str} + class FrozenDictTupleDecimalMixin: + _types = {frozendict.frozendict, tuple, decimal.Decimal} + class FrozenDictTupleBoolMixin: + _types = {frozendict.frozendict, tuple, BoolClass} + class FrozenDictStrDecimalMixin: + _types = {frozendict.frozendict, str, decimal.Decimal} + class FrozenDictStrBoolMixin: + _types = {frozendict.frozendict, str, BoolClass} + class FrozenDictDecimalBoolMixin: + _types = {frozendict.frozendict, decimal.Decimal, BoolClass} + class TupleStrDecimalMixin: + _types = {tuple, str, decimal.Decimal} + class TupleStrBoolMixin: + _types = {tuple, str, BoolClass} + class TupleDecimalBoolMixin: + _types = {tuple, decimal.Decimal, BoolClass} + class StrDecimalBoolMixin: + _types = {str, decimal.Decimal, BoolClass} + # qty 4 + class NoneFrozenDictTupleStrMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str} + class NoneFrozenDictTupleDecimalMixin: + _types = {NoneClass, frozendict.frozendict, tuple, decimal.Decimal} + class NoneFrozenDictTupleBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, BoolClass} + class NoneFrozenDictStrDecimalMixin: + _types = {NoneClass, frozendict.frozendict, str, decimal.Decimal} + class NoneFrozenDictStrBoolMixin: + _types = {NoneClass, frozendict.frozendict, str, BoolClass} + class NoneFrozenDictDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, decimal.Decimal, BoolClass} + class NoneTupleStrDecimalMixin: + _types = {NoneClass, tuple, str, decimal.Decimal} + class NoneTupleStrBoolMixin: + _types = {NoneClass, tuple, str, BoolClass} + class NoneTupleDecimalBoolMixin: + _types = {NoneClass, tuple, decimal.Decimal, BoolClass} + class NoneStrDecimalBoolMixin: + _types = {NoneClass, str, decimal.Decimal, BoolClass} + class FrozenDictTupleStrDecimalMixin: + _types = {frozendict.frozendict, tuple, str, decimal.Decimal} + class FrozenDictTupleStrBoolMixin: + _types = {frozendict.frozendict, tuple, str, BoolClass} + class FrozenDictTupleDecimalBoolMixin: + _types = {frozendict.frozendict, tuple, decimal.Decimal, BoolClass} + class FrozenDictStrDecimalBoolMixin: + _types = {frozendict.frozendict, str, decimal.Decimal, BoolClass} + class TupleStrDecimalBoolMixin: + _types = {tuple, str, decimal.Decimal, BoolClass} + # qty 5 + class NoneFrozenDictTupleStrDecimalMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal} + class NoneFrozenDictTupleStrBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, BoolClass} + class NoneFrozenDictTupleDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, decimal.Decimal, BoolClass} + class NoneFrozenDictStrDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, str, decimal.Decimal, BoolClass} + class NoneTupleStrDecimalBoolMixin: + _types = {NoneClass, tuple, str, decimal.Decimal, BoolClass} + class FrozenDictTupleStrDecimalBoolMixin: + _types = {frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass} + # qty 6 + class NoneFrozenDictTupleStrDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass} + # qty 8 + class NoneFrozenDictTupleStrDecimalBoolFileBytesMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass, FileIO, bytes} + + +class ValidatorBase: + @staticmethod + def _is_json_validation_enabled_oapg(schema_keyword, configuration=None): + \\"\\"\\"Returns true if JSON schema validation is enabled for the specified + validation keyword. This can be used to skip JSON schema structural validation + as requested in the configuration. + Note: the suffix _oapg stands for openapi python (experimental) generator and + it has been added to prevent collisions with other methods and properties + + Args: + schema_keyword (string): the name of a JSON schema validation keyword. + configuration (Configuration): the configuration class. + \\"\\"\\" + + return (configuration is None or + not hasattr(configuration, '_disabled_client_side_validations') or + schema_keyword not in configuration._disabled_client_side_validations) + + @staticmethod + def _raise_validation_error_message_oapg(value, constraint_msg, constraint_value, path_to_item, additional_txt=\\"\\"): + raise ApiValueError( + \\"Invalid value \`{value}\`, {constraint_msg} \`{constraint_value}\`{additional_txt} at {path_to_item}\\".format( + value=value, + constraint_msg=constraint_msg, + constraint_value=constraint_value, + additional_txt=additional_txt, + path_to_item=path_to_item, + ) + ) + + +class EnumBase: + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: + \\"\\"\\" + EnumBase _validate_oapg + Validates that arg is in the enum's allowed values + \\"\\"\\" + try: + cls.MetaOapg.enum_value_to_name[arg] + except KeyError: + raise ApiValueError(\\"Invalid value {} passed in to {}, allowed_values={}\\".format(arg, cls, cls.MetaOapg.enum_value_to_name.keys())) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class BoolBase: + def is_true_oapg(self) -> bool: + \\"\\"\\" + A replacement for x is True + True if the instance is a BoolClass True Singleton + \\"\\"\\" + if not issubclass(self.__class__, BoolClass): + return False + return bool(self) + + def is_false_oapg(self) -> bool: + \\"\\"\\" + A replacement for x is False + True if the instance is a BoolClass False Singleton + \\"\\"\\" + if not issubclass(self.__class__, BoolClass): + return False + return bool(self) is False + + +class NoneBase: + def is_none_oapg(self) -> bool: + \\"\\"\\" + A replacement for x is None + True if the instance is a NoneClass None Singleton + \\"\\"\\" + if issubclass(self.__class__, NoneClass): + return True + return False + + +class StrBase(ValidatorBase): + MetaOapg: MetaOapgTyped + + @property + def as_str_oapg(self) -> str: + return self + + @property + def as_date_oapg(self) -> date: + raise Exception('not implemented') + + @property + def as_datetime_oapg(self) -> datetime: + raise Exception('not implemented') + + @property + def as_decimal_oapg(self) -> decimal.Decimal: + raise Exception('not implemented') + + @property + def as_uuid_oapg(self) -> uuid.UUID: + raise Exception('not implemented') + + @classmethod + def __check_str_validations( + cls, + arg: str, + validation_metadata: ValidationMetadata + ): + if not hasattr(cls, 'MetaOapg'): + return + if (cls._is_json_validation_enabled_oapg('maxLength', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'max_length') and + len(arg) > cls.MetaOapg.max_length): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"length must be less than or equal to\\", + constraint_value=cls.MetaOapg.max_length, + path_to_item=validation_metadata.path_to_item + ) + + if (cls._is_json_validation_enabled_oapg('minLength', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'min_length') and + len(arg) < cls.MetaOapg.min_length): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"length must be greater than or equal to\\", + constraint_value=cls.MetaOapg.min_length, + path_to_item=validation_metadata.path_to_item + ) + + if (cls._is_json_validation_enabled_oapg('pattern', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'regex')): + for regex_dict in cls.MetaOapg.regex: + flags = regex_dict.get('flags', 0) + if not re.search(regex_dict['pattern'], arg, flags=flags): + if flags != 0: + # Don't print the regex flags if the flags are not + # specified in the OAS document. + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"must match regular expression\\", + constraint_value=regex_dict['pattern'], + path_to_item=validation_metadata.path_to_item, + additional_txt=\\" with flags=\`{}\`\\".format(flags) + ) + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"must match regular expression\\", + constraint_value=regex_dict['pattern'], + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: + \\"\\"\\" + StrBase _validate_oapg + Validates that validations pass + \\"\\"\\" + if isinstance(arg, str): + cls.__check_str_validations(arg, validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class UUIDBase: + @property + @functools.lru_cache() + def as_uuid_oapg(self) -> uuid.UUID: + return uuid.UUID(self) + + @classmethod + def __validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + uuid.UUID(arg) + return True + except ValueError: + raise ApiValueError( + \\"Invalid value '{}' for type UUID at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: typing.Optional[ValidationMetadata] = None, + ): + \\"\\"\\" + UUIDBase _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class CustomIsoparser(isoparser): + + @_takes_ascii + def parse_isodatetime(self, dt_str): + components, pos = self._parse_isodate(dt_str) + if len(dt_str) > pos: + if self._sep is None or dt_str[pos:pos + 1] == self._sep: + components += self._parse_isotime(dt_str[pos + 1:]) + else: + raise ValueError('String contains unknown ISO components') + + if len(components) > 3 and components[3] == 24: + components[3] = 0 + return datetime(*components) + timedelta(days=1) + + if len(components) <= 3: + raise ValueError('Value is not a datetime') + + return datetime(*components) + + @_takes_ascii + def parse_isodate(self, datestr): + components, pos = self._parse_isodate(datestr) + + if len(datestr) > pos: + raise ValueError('String contains invalid time components') + + if len(components) > 3: + raise ValueError('String contains invalid time components') + + return date(*components) + + +DEFAULT_ISOPARSER = CustomIsoparser() + + +class DateBase: + @property + @functools.lru_cache() + def as_date_oapg(self) -> date: + return DEFAULT_ISOPARSER.parse_isodate(self) + + @classmethod + def __validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + DEFAULT_ISOPARSER.parse_isodate(arg) + return True + except ValueError: + raise ApiValueError( + \\"Value does not conform to the required ISO-8601 date format. \\" + \\"Invalid value '{}' for type date at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: typing.Optional[ValidationMetadata] = None, + ): + \\"\\"\\" + DateBase _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class DateTimeBase: + @property + @functools.lru_cache() + def as_datetime_oapg(self) -> datetime: + return DEFAULT_ISOPARSER.parse_isodatetime(self) + + @classmethod + def __validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + DEFAULT_ISOPARSER.parse_isodatetime(arg) + return True + except ValueError: + raise ApiValueError( + \\"Value does not conform to the required ISO-8601 datetime format. \\" + \\"Invalid value '{}' for type datetime at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + DateTimeBase _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class DecimalBase: + \\"\\"\\" + A class for storing decimals that are sent over the wire as strings + These schemas must remain based on StrBase rather than NumberBase + because picking base classes must be deterministic + \\"\\"\\" + + @property + @functools.lru_cache() + def as_decimal_oapg(self) -> decimal.Decimal: + return decimal.Decimal(self) + + @classmethod + def __validate_format(cls, arg: typing.Optional[str], validation_metadata: ValidationMetadata): + if isinstance(arg, str): + try: + decimal.Decimal(arg) + return True + except decimal.InvalidOperation: + raise ApiValueError( + \\"Value cannot be converted to a decimal. \\" + \\"Invalid value '{}' for type decimal at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + DecimalBase _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class NumberBase(ValidatorBase): + MetaOapg: MetaOapgTyped + + @property + def as_int_oapg(self) -> int: + try: + return self._as_int + except AttributeError: + \\"\\"\\" + Note: for some numbers like 9.0 they could be represented as an + integer but our code chooses to store them as + >>> Decimal('9.0').as_tuple() + DecimalTuple(sign=0, digits=(9, 0), exponent=-1) + so we can tell that the value came from a float and convert it back to a float + during later serialization + \\"\\"\\" + if self.as_tuple().exponent < 0: + # this could be represented as an integer but should be represented as a float + # because that's what it was serialized from + raise ApiValueError(f'{self} is not an integer') + self._as_int = int(self) + return self._as_int + + @property + def as_float_oapg(self) -> float: + try: + return self._as_float + except AttributeError: + if self.as_tuple().exponent >= 0: + raise ApiValueError(f'{self} is not a float') + self._as_float = float(self) + return self._as_float + + @classmethod + def __check_numeric_validations( + cls, + arg, + validation_metadata: ValidationMetadata + ): + if not hasattr(cls, 'MetaOapg'): + return + if cls._is_json_validation_enabled_oapg('multipleOf', + validation_metadata.configuration) and hasattr(cls.MetaOapg, 'multiple_of'): + multiple_of_value = cls.MetaOapg.multiple_of + if (not (float(arg) / multiple_of_value).is_integer()): + # Note 'multipleOf' will be as good as the floating point arithmetic. + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"value must be a multiple of\\", + constraint_value=multiple_of_value, + path_to_item=validation_metadata.path_to_item + ) + + checking_max_or_min_values = any( + hasattr(cls.MetaOapg, validation_key) for validation_key in { + 'exclusive_maximum', + 'inclusive_maximum', + 'exclusive_minimum', + 'inclusive_minimum', + } + ) + if not checking_max_or_min_values: + return + + if (cls._is_json_validation_enabled_oapg('exclusiveMaximum', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'exclusive_maximum') and + arg >= cls.MetaOapg.exclusive_maximum): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"must be a value less than\\", + constraint_value=cls.MetaOapg.exclusive_maximum, + path_to_item=validation_metadata.path_to_item + ) + + if (cls._is_json_validation_enabled_oapg('maximum', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'inclusive_maximum') and + arg > cls.MetaOapg.inclusive_maximum): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"must be a value less than or equal to\\", + constraint_value=cls.MetaOapg.inclusive_maximum, + path_to_item=validation_metadata.path_to_item + ) + + if (cls._is_json_validation_enabled_oapg('exclusiveMinimum', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'exclusive_minimum') and + arg <= cls.MetaOapg.exclusive_minimum): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"must be a value greater than\\", + constraint_value=cls.MetaOapg.exclusive_maximum, + path_to_item=validation_metadata.path_to_item + ) + + if (cls._is_json_validation_enabled_oapg('minimum', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'inclusive_minimum') and + arg < cls.MetaOapg.inclusive_minimum): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"must be a value greater than or equal to\\", + constraint_value=cls.MetaOapg.inclusive_minimum, + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: + \\"\\"\\" + NumberBase _validate_oapg + Validates that validations pass + \\"\\"\\" + if isinstance(arg, decimal.Decimal): + cls.__check_numeric_validations(arg, validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class ListBase(ValidatorBase): + MetaOapg: MetaOapgTyped + + @classmethod + def __validate_items(cls, list_items, validation_metadata: ValidationMetadata): + \\"\\"\\" + Ensures that: + - values passed in for items are valid + Exceptions will be raised if: + - invalid arguments were passed in + + Args: + list_items: the input list of items + + Raises: + ApiTypeError - for missing required arguments, or for invalid properties + \\"\\"\\" + + # if we have definitions for an items schema, use it + # otherwise accept anything + item_cls = getattr(cls.MetaOapg, 'items', UnsetAnyTypeSchema) + item_cls = cls._get_class_oapg(item_cls) + path_to_schemas = {} + for i, value in enumerate(list_items): + item_validation_metadata = ValidationMetadata( + from_server=validation_metadata.from_server, + configuration=validation_metadata.configuration, + path_to_item=validation_metadata.path_to_item+(i,), + validated_path_to_schemas=validation_metadata.validated_path_to_schemas + ) + if item_validation_metadata.validation_ran_earlier(item_cls): + add_deeper_validated_schemas(item_validation_metadata, path_to_schemas) + continue + other_path_to_schemas = item_cls._validate_oapg( + value, validation_metadata=item_validation_metadata) + update(path_to_schemas, other_path_to_schemas) + return path_to_schemas + + @classmethod + def __check_tuple_validations( + cls, arg, + validation_metadata: ValidationMetadata): + if not hasattr(cls, 'MetaOapg'): + return + if (cls._is_json_validation_enabled_oapg('maxItems', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'max_items') and + len(arg) > cls.MetaOapg.max_items): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"number of items must be less than or equal to\\", + constraint_value=cls.MetaOapg.max_items, + path_to_item=validation_metadata.path_to_item + ) + + if (cls._is_json_validation_enabled_oapg('minItems', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'min_items') and + len(arg) < cls.MetaOapg.min_items): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"number of items must be greater than or equal to\\", + constraint_value=cls.MetaOapg.min_items, + path_to_item=validation_metadata.path_to_item + ) + + if (cls._is_json_validation_enabled_oapg('uniqueItems', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'unique_items') and cls.MetaOapg.unique_items and arg): + unique_items = set(arg) + if len(arg) > len(unique_items): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"duplicate items were found, and the tuple must not contain duplicates because\\", + constraint_value='unique_items==True', + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + ListBase _validate_oapg + We return dynamic classes of different bases depending upon the inputs + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Returns: + new_cls (type): the new class + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + \\"\\"\\" + if isinstance(arg, tuple): + cls.__check_tuple_validations(arg, validation_metadata) + _path_to_schemas = super()._validate_oapg(arg, validation_metadata=validation_metadata) + if not isinstance(arg, tuple): + return _path_to_schemas + updated_vm = ValidationMetadata( + configuration=validation_metadata.configuration, + from_server=validation_metadata.from_server, + path_to_item=validation_metadata.path_to_item, + seen_classes=validation_metadata.seen_classes | frozenset({cls}), + validated_path_to_schemas=validation_metadata.validated_path_to_schemas + ) + other_path_to_schemas = cls.__validate_items(arg, validation_metadata=updated_vm) + update(_path_to_schemas, other_path_to_schemas) + return _path_to_schemas + + @classmethod + def _get_items_oapg( + cls: 'Schema', + arg: typing.List[typing.Any], + path_to_item: typing.Tuple[typing.Union[str, int], ...], + path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] + ): + ''' + ListBase _get_items_oapg + ''' + cast_items = [] + + for i, value in enumerate(arg): + item_path_to_item = path_to_item + (i,) + item_cls = path_to_schemas[item_path_to_item] + new_value = item_cls._get_new_instance_without_conversion_oapg( + value, + item_path_to_item, + path_to_schemas + ) + cast_items.append(new_value) + + return cast_items + + +class Discriminable: + MetaOapg: MetaOapgTyped + + @classmethod + def _ensure_discriminator_value_present_oapg(cls, disc_property_name: str, validation_metadata: ValidationMetadata, *args): + if not args or args and disc_property_name not in args[0]: + # The input data does not contain the discriminator property + raise ApiValueError( + \\"Cannot deserialize input data due to missing discriminator. \\" + \\"The discriminator property '{}' is missing at path: {}\\".format(disc_property_name, validation_metadata.path_to_item) + ) + + @classmethod + def get_discriminated_class_oapg(cls, disc_property_name: str, disc_payload_value: str): + \\"\\"\\" + Used in schemas with discriminators + \\"\\"\\" + if not hasattr(cls.MetaOapg, 'discriminator'): + return None + disc = cls.MetaOapg.discriminator() + if disc_property_name not in disc: + return None + discriminated_cls = disc[disc_property_name].get(disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + if not hasattr(cls, 'MetaOapg'): + return None + elif not ( + hasattr(cls.MetaOapg, 'all_of') or + hasattr(cls.MetaOapg, 'one_of') or + hasattr(cls.MetaOapg, 'any_of') + ): + return None + # TODO stop traveling if a cycle is hit + if hasattr(cls.MetaOapg, 'all_of'): + for allof_cls in cls.MetaOapg.all_of(): + discriminated_cls = allof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + if hasattr(cls.MetaOapg, 'one_of'): + for oneof_cls in cls.MetaOapg.one_of(): + discriminated_cls = oneof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + if hasattr(cls.MetaOapg, 'any_of'): + for anyof_cls in cls.MetaOapg.any_of(): + discriminated_cls = anyof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + return None + + +class DictBase(Discriminable, ValidatorBase): + + @classmethod + def __validate_arg_presence(cls, arg): + \\"\\"\\" + Ensures that: + - all required arguments are passed in + - the input variable names are valid + - present in properties or + - accepted because additionalProperties exists + Exceptions will be raised if: + - invalid arguments were passed in + - a var_name is invalid if additional_properties == NotAnyTypeSchema + and var_name not in properties.__annotations__ + - required properties were not passed in + + Args: + arg: the input dict + + Raises: + ApiTypeError - for missing required arguments, or for invalid properties + \\"\\"\\" + seen_required_properties = set() + invalid_arguments = [] + required_property_names = getattr(cls.MetaOapg, 'required', set()) + additional_properties = getattr(cls.MetaOapg, 'additional_properties', UnsetAnyTypeSchema) + properties = getattr(cls.MetaOapg, 'properties', {}) + property_annotations = getattr(properties, '__annotations__', {}) + for property_name in arg: + if property_name in required_property_names: + seen_required_properties.add(property_name) + elif property_name in property_annotations: + continue + elif additional_properties is not NotAnyTypeSchema: + continue + else: + invalid_arguments.append(property_name) + missing_required_arguments = list(required_property_names - seen_required_properties) + if missing_required_arguments: + missing_required_arguments.sort() + raise ApiTypeError( + \\"{} is missing {} required argument{}: {}\\".format( + cls.__name__, + len(missing_required_arguments), + \\"s\\" if len(missing_required_arguments) > 1 else \\"\\", + missing_required_arguments + ) + ) + if invalid_arguments: + invalid_arguments.sort() + raise ApiTypeError( + \\"{} was passed {} invalid argument{}: {}\\".format( + cls.__name__, + len(invalid_arguments), + \\"s\\" if len(invalid_arguments) > 1 else \\"\\", + invalid_arguments + ) + ) + + @classmethod + def __validate_args(cls, arg, validation_metadata: ValidationMetadata): + \\"\\"\\" + Ensures that: + - values passed in for properties are valid + Exceptions will be raised if: + - invalid arguments were passed in + + Args: + arg: the input dict + + Raises: + ApiTypeError - for missing required arguments, or for invalid properties + \\"\\"\\" + path_to_schemas = {} + additional_properties = getattr(cls.MetaOapg, 'additional_properties', UnsetAnyTypeSchema) + properties = getattr(cls.MetaOapg, 'properties', {}) + property_annotations = getattr(properties, '__annotations__', {}) + for property_name, value in arg.items(): + path_to_item = validation_metadata.path_to_item+(property_name,) + if property_name in property_annotations: + schema = property_annotations[property_name] + elif additional_properties is not NotAnyTypeSchema: + if additional_properties is UnsetAnyTypeSchema: + \\"\\"\\" + If additionalProperties is unset and this path_to_item does not yet have + any validations on it, validate it. + If it already has validations on it, skip this validation. + \\"\\"\\" + if path_to_item in path_to_schemas: + continue + schema = additional_properties + else: + raise ApiTypeError('Unable to find schema for value={} in class={} at path_to_item={}'.format( + value, cls, validation_metadata.path_to_item+(property_name,) + )) + schema = cls._get_class_oapg(schema) + arg_validation_metadata = ValidationMetadata( + from_server=validation_metadata.from_server, + configuration=validation_metadata.configuration, + path_to_item=path_to_item, + validated_path_to_schemas=validation_metadata.validated_path_to_schemas + ) + if arg_validation_metadata.validation_ran_earlier(schema): + add_deeper_validated_schemas(arg_validation_metadata, path_to_schemas) + continue + other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata) + update(path_to_schemas, other_path_to_schemas) + return path_to_schemas + + @classmethod + def __check_dict_validations( + cls, + arg, + validation_metadata: ValidationMetadata + ): + if not hasattr(cls, 'MetaOapg'): + return + if (cls._is_json_validation_enabled_oapg('maxProperties', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'max_properties') and + len(arg) > cls.MetaOapg.max_properties): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"number of properties must be less than or equal to\\", + constraint_value=cls.MetaOapg.max_properties, + path_to_item=validation_metadata.path_to_item + ) + + if (cls._is_json_validation_enabled_oapg('minProperties', validation_metadata.configuration) and + hasattr(cls.MetaOapg, 'min_properties') and + len(arg) < cls.MetaOapg.min_properties): + cls._raise_validation_error_message_oapg( + value=arg, + constraint_msg=\\"number of properties must be greater than or equal to\\", + constraint_value=cls.MetaOapg.min_properties, + path_to_item=validation_metadata.path_to_item + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + DictBase _validate_oapg + We return dynamic classes of different bases depending upon the inputs + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Returns: + new_cls (type): the new class + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + \\"\\"\\" + if isinstance(arg, frozendict.frozendict): + cls.__check_dict_validations(arg, validation_metadata) + _path_to_schemas = super()._validate_oapg(arg, validation_metadata=validation_metadata) + if not isinstance(arg, frozendict.frozendict): + return _path_to_schemas + cls.__validate_arg_presence(arg) + other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata) + update(_path_to_schemas, other_path_to_schemas) + try: + discriminator = cls.MetaOapg.discriminator() + except AttributeError: + return _path_to_schemas + # discriminator exists + disc_prop_name = list(discriminator.keys())[0] + cls._ensure_discriminator_value_present_oapg(disc_prop_name, validation_metadata, arg) + discriminated_cls = cls.get_discriminated_class_oapg( + disc_property_name=disc_prop_name, disc_payload_value=arg[disc_prop_name]) + if discriminated_cls is None: + raise ApiValueError( + \\"Invalid discriminator value was passed in to {}.{} Only the values {} are allowed at {}\\".format( + cls.__name__, + disc_prop_name, + list(discriminator[disc_prop_name].keys()), + validation_metadata.path_to_item + (disc_prop_name,) + ) + ) + updated_vm = ValidationMetadata( + configuration=validation_metadata.configuration, + from_server=validation_metadata.from_server, + path_to_item=validation_metadata.path_to_item, + seen_classes=validation_metadata.seen_classes | frozenset({cls}), + validated_path_to_schemas=validation_metadata.validated_path_to_schemas + ) + if updated_vm.validation_ran_earlier(discriminated_cls): + add_deeper_validated_schemas(updated_vm, _path_to_schemas) + return _path_to_schemas + other_path_to_schemas = discriminated_cls._validate_oapg(arg, validation_metadata=updated_vm) + update(_path_to_schemas, other_path_to_schemas) + return _path_to_schemas + + @classmethod + def _get_properties_oapg( + cls, + arg: typing.Dict[str, typing.Any], + path_to_item: typing.Tuple[typing.Union[str, int], ...], + path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Type['Schema']] + ): + \\"\\"\\" + DictBase _get_properties_oapg, this is how properties are set + These values already passed validation + \\"\\"\\" + dict_items = {} + + for property_name_js, value in arg.items(): + property_path_to_item = path_to_item + (property_name_js,) + property_cls = path_to_schemas[property_path_to_item] + new_value = property_cls._get_new_instance_without_conversion_oapg( + value, + property_path_to_item, + path_to_schemas + ) + dict_items[property_name_js] = new_value + + return dict_items + + def __setattr__(self, name: str, value: typing.Any): + if not isinstance(self, FileIO): + raise AttributeError('property setting not supported on immutable instances') + + def __getattr__(self, name: str): + \\"\\"\\" + for instance.name access + Properties are only type hinted for required properties + so that hasattr(instance, 'optionalProp') is False when that key is not present + \\"\\"\\" + if not isinstance(self, frozendict.frozendict): + return super().__getattr__(name) + if name not in self.__class__.__annotations__: + raise AttributeError(f\\"{self} has no attribute '{name}'\\") + try: + value = self[name] + return value + except KeyError as ex: + raise AttributeError(str(ex)) + + def __getitem__(self, name: str): + \\"\\"\\" + dict_instance[name] accessor + key errors thrown + \\"\\"\\" + if not isinstance(self, frozendict.frozendict): + return super().__getattr__(name) + return super().__getitem__(name) + + def get_item_oapg(self, name: str) -> typing.Union['AnyTypeSchema', Unset]: + # dict_instance[name] accessor + if not isinstance(self, frozendict.frozendict): + raise NotImplementedError() + try: + return super().__getitem__(name) + except KeyError: + return unset + + +def cast_to_allowed_types( + arg: typing.Union[str, date, datetime, uuid.UUID, decimal.Decimal, int, float, None, dict, frozendict.frozendict, list, tuple, bytes, Schema, io.FileIO, io.BufferedReader], + from_server: bool, + validated_path_to_schemas: typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]], + path_to_item: typing.Tuple[typing.Union[str, int], ...] = tuple(['args[0]']), +) -> typing.Union[frozendict.frozendict, tuple, decimal.Decimal, str, bytes, BoolClass, NoneClass, FileIO]: + \\"\\"\\" + Casts the input payload arg into the allowed types + The input validated_path_to_schemas is mutated by running this function + + When from_server is False then + - date/datetime is cast to str + - int/float is cast to Decimal + + If a Schema instance is passed in it is converted back to a primitive instance because + One may need to validate that data to the original Schema class AND additional different classes + those additional classes will need to be added to the new manufactured class for that payload + If the code didn't do this and kept the payload as a Schema instance it would fail to validate to other + Schema classes and the code wouldn't be able to mfg a new class that includes all valid schemas + TODO: store the validated schema classes in validation_metadata + + Args: + arg: the payload + from_server: whether this payload came from the server or not + validated_path_to_schemas: a dict that stores the validated classes at any path location in the payload + \\"\\"\\" + if isinstance(arg, Schema): + # store the already run validations + schema_classes = set() + for cls in arg.__class__.__bases__: + if cls is Singleton: + # Skip Singleton + continue + schema_classes.add(cls) + validated_path_to_schemas[path_to_item] = schema_classes + + type_error = ApiTypeError(f\\"Invalid type. Required value type is str and passed type was {type(arg)} at {path_to_item}\\") + if isinstance(arg, str): + return str(arg) + elif isinstance(arg, (dict, frozendict.frozendict)): + return frozendict.frozendict({key: cast_to_allowed_types(val, from_server, validated_path_to_schemas, path_to_item + (key,)) for key, val in arg.items()}) + elif isinstance(arg, (bool, BoolClass)): + \\"\\"\\" + this check must come before isinstance(arg, (int, float)) + because isinstance(True, int) is True + \\"\\"\\" + if arg: + return BoolClass.TRUE + return BoolClass.FALSE + elif isinstance(arg, int): + return decimal.Decimal(arg) + elif isinstance(arg, float): + decimal_from_float = decimal.Decimal(arg) + if decimal_from_float.as_integer_ratio()[1] == 1: + # 9.0 -> Decimal('9.0') + # 3.4028234663852886e+38 -> Decimal('340282346638528859811704183484516925440.0') + return decimal.Decimal(str(decimal_from_float)+'.0') + return decimal_from_float + elif isinstance(arg, (tuple, list)): + return tuple([cast_to_allowed_types(item, from_server, validated_path_to_schemas, path_to_item + (i,)) for i, item in enumerate(arg)]) + elif isinstance(arg, (none_type, NoneClass)): + return NoneClass.NONE + elif isinstance(arg, (date, datetime)): + if not from_server: + return arg.isoformat() + raise type_error + elif isinstance(arg, uuid.UUID): + if not from_server: + return str(arg) + raise type_error + elif isinstance(arg, decimal.Decimal): + return decimal.Decimal(arg) + elif isinstance(arg, bytes): + return bytes(arg) + elif isinstance(arg, (io.FileIO, io.BufferedReader)): + return FileIO(arg) + raise ValueError('Invalid type passed in got input={} type={}'.format(arg, type(arg))) + + +class ComposedBase(Discriminable): + + @classmethod + def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): + path_to_schemas = defaultdict(set) + for allof_cls in cls.MetaOapg.all_of(): + if validation_metadata.validation_ran_earlier(allof_cls): + add_deeper_validated_schemas(validation_metadata, path_to_schemas) + continue + other_path_to_schemas = allof_cls._validate_oapg(arg, validation_metadata=validation_metadata) + update(path_to_schemas, other_path_to_schemas) + return path_to_schemas + + @classmethod + def __get_oneof_class( + cls, + arg, + discriminated_cls, + validation_metadata: ValidationMetadata, + ): + oneof_classes = [] + path_to_schemas = defaultdict(set) + for oneof_cls in cls.MetaOapg.one_of(): + if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: + oneof_classes.append(oneof_cls) + continue + if validation_metadata.validation_ran_earlier(oneof_cls): + oneof_classes.append(oneof_cls) + add_deeper_validated_schemas(validation_metadata, path_to_schemas) + continue + try: + path_to_schemas = oneof_cls._validate_oapg(arg, validation_metadata=validation_metadata) + except (ApiValueError, ApiTypeError) as ex: + if discriminated_cls is not None and oneof_cls is discriminated_cls: + raise ex + continue + oneof_classes.append(oneof_cls) + if not oneof_classes: + raise ApiValueError( + \\"Invalid inputs given to generate an instance of {}. None \\" + \\"of the oneOf schemas matched the input data.\\".format(cls) + ) + elif len(oneof_classes) > 1: + raise ApiValueError( + \\"Invalid inputs given to generate an instance of {}. Multiple \\" + \\"oneOf schemas {} matched the inputs, but a max of one is allowed.\\".format(cls, oneof_classes) + ) + # exactly one class matches + return path_to_schemas + + @classmethod + def __get_anyof_classes( + cls, + arg, + discriminated_cls, + validation_metadata: ValidationMetadata + ): + anyof_classes = [] + path_to_schemas = defaultdict(set) + for anyof_cls in cls.MetaOapg.any_of(): + if validation_metadata.validation_ran_earlier(anyof_cls): + anyof_classes.append(anyof_cls) + add_deeper_validated_schemas(validation_metadata, path_to_schemas) + continue + + try: + other_path_to_schemas = anyof_cls._validate_oapg(arg, validation_metadata=validation_metadata) + except (ApiValueError, ApiTypeError) as ex: + if discriminated_cls is not None and anyof_cls is discriminated_cls: + raise ex + continue + anyof_classes.append(anyof_cls) + update(path_to_schemas, other_path_to_schemas) + if not anyof_classes: + raise ApiValueError( + \\"Invalid inputs given to generate an instance of {}. None \\" + \\"of the anyOf schemas matched the input data.\\".format(cls) + ) + return path_to_schemas + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: + \\"\\"\\" + ComposedBase _validate_oapg + We return dynamic classes of different bases depending upon the inputs + This makes it so: + - the returned instance is always a subclass of our defining schema + - this allows us to check type based on whether an instance is a subclass of a schema + - the returned instance is a serializable type (except for None, True, and False) which are enums + + Returns: + new_cls (type): the new class + + Raises: + ApiValueError: when a string can't be converted into a date or datetime and it must be one of those classes + ApiTypeError: when the input type is not in the list of allowed spec types + \\"\\"\\" + # validation checking on types, validations, and enums + path_to_schemas = super()._validate_oapg(arg, validation_metadata=validation_metadata) + + updated_vm = ValidationMetadata( + configuration=validation_metadata.configuration, + from_server=validation_metadata.from_server, + path_to_item=validation_metadata.path_to_item, + seen_classes=validation_metadata.seen_classes | frozenset({cls}), + validated_path_to_schemas=validation_metadata.validated_path_to_schemas + ) + + # process composed schema + discriminator = None + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'discriminator'): + discriminator = cls.MetaOapg.discriminator() + discriminated_cls = None + if discriminator and arg and isinstance(arg, frozendict.frozendict): + disc_property_name = list(discriminator.keys())[0] + cls._ensure_discriminator_value_present_oapg(disc_property_name, updated_vm, arg) + # get discriminated_cls by looking at the dict in the current class + discriminated_cls = cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=arg[disc_property_name]) + if discriminated_cls is None: + raise ApiValueError( + \\"Invalid discriminator value '{}' was passed in to {}.{} Only the values {} are allowed at {}\\".format( + arg[disc_property_name], + cls.__name__, + disc_property_name, + list(discriminator[disc_property_name].keys()), + updated_vm.path_to_item + (disc_property_name,) + ) + ) + + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'all_of'): + other_path_to_schemas = cls.__get_allof_classes(arg, validation_metadata=updated_vm) + update(path_to_schemas, other_path_to_schemas) + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'one_of'): + other_path_to_schemas = cls.__get_oneof_class( + arg, + discriminated_cls=discriminated_cls, + validation_metadata=updated_vm + ) + update(path_to_schemas, other_path_to_schemas) + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'any_of'): + other_path_to_schemas = cls.__get_anyof_classes( + arg, + discriminated_cls=discriminated_cls, + validation_metadata=updated_vm + ) + update(path_to_schemas, other_path_to_schemas) + not_cls = None + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'not_schema'): + not_cls = cls.MetaOapg.not_schema + not_cls = cls._get_class_oapg(not_cls) + if not_cls: + other_path_to_schemas = None + not_exception = ApiValueError( + \\"Invalid value '{}' was passed in to {}. Value is invalid because it is disallowed by {}\\".format( + arg, + cls.__name__, + not_cls.__name__, + ) + ) + if updated_vm.validation_ran_earlier(not_cls): + raise not_exception + + try: + other_path_to_schemas = not_cls._validate_oapg(arg, validation_metadata=updated_vm) + except (ApiValueError, ApiTypeError): + pass + if other_path_to_schemas: + raise not_exception + + if discriminated_cls is not None and not updated_vm.validation_ran_earlier(discriminated_cls): + # TODO use an exception from this package here + add_deeper_validated_schemas(updated_vm, path_to_schemas) + assert discriminated_cls in path_to_schemas[updated_vm.path_to_item] + return path_to_schemas + + +# DictBase, ListBase, NumberBase, StrBase, BoolBase, NoneBase +class ComposedSchema( + ComposedBase, + DictBase, + ListBase, + NumberBase, + StrBase, + BoolBase, + NoneBase, + Schema, + NoneFrozenDictTupleStrDecimalBoolMixin +): + @classmethod + def from_openapi_data_oapg(cls, *args: typing.Any, _configuration: typing.Optional[Configuration] = None, **kwargs): + if not args: + if not kwargs: + raise ApiTypeError('{} is missing required input data in args or kwargs'.format(cls.__name__)) + args = (kwargs, ) + return super().from_openapi_data_oapg(args[0], _configuration=_configuration) + + +class ListSchema( + ListBase, + Schema, + TupleMixin +): + + @classmethod + def from_openapi_data_oapg(cls, arg: typing.List[typing.Any], _configuration: typing.Optional[Configuration] = None): + return super().from_openapi_data_oapg(arg, _configuration=_configuration) + + def __new__(cls, _arg: typing.Union[typing.List[typing.Any], typing.Tuple[typing.Any]], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) + + +class NoneSchema( + NoneBase, + Schema, + NoneMixin +): + + @classmethod + def from_openapi_data_oapg(cls, arg: None, _configuration: typing.Optional[Configuration] = None): + return super().from_openapi_data_oapg(arg, _configuration=_configuration) + + def __new__(cls, _arg: None, **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) + + +class NumberSchema( + NumberBase, + Schema, + DecimalMixin +): + \\"\\"\\" + This is used for type: number with no format + Both integers AND floats are accepted + \\"\\"\\" + + @classmethod + def from_openapi_data_oapg(cls, arg: typing.Union[int, float], _configuration: typing.Optional[Configuration] = None): + return super().from_openapi_data_oapg(arg, _configuration=_configuration) + + def __new__(cls, _arg: typing.Union[decimal.Decimal, int, float], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) + + +class IntBase: + @property + def as_int_oapg(self) -> int: + try: + return self._as_int + except AttributeError: + self._as_int = int(self) + return self._as_int + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + + denominator = arg.as_integer_ratio()[-1] + if denominator != 1: + raise ApiValueError( + \\"Invalid value '{}' for type integer at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + IntBase _validate_oapg + TODO what about types = (int, number) -> IntBase, NumberBase? We could drop int and keep number only + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class IntSchema(IntBase, NumberSchema): + + @classmethod + def from_openapi_data_oapg(cls, arg: int, _configuration: typing.Optional[Configuration] = None): + return super().from_openapi_data_oapg(arg, _configuration=_configuration) + + def __new__(cls, _arg: typing.Union[decimal.Decimal, int], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) + + +class Int32Base: + __inclusive_minimum = decimal.Decimal(-2147483648) + __inclusive_maximum = decimal.Decimal(2147483647) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal) and arg.as_tuple().exponent == 0: + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type int32 at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Int32Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class Int32Schema( + Int32Base, + IntSchema +): + pass + + +class Int64Base: + __inclusive_minimum = decimal.Decimal(-9223372036854775808) + __inclusive_maximum = decimal.Decimal(9223372036854775807) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal) and arg.as_tuple().exponent == 0: + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type int64 at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Int64Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class Int64Schema( + Int64Base, + IntSchema +): + pass + + +class Float32Base: + __inclusive_minimum = decimal.Decimal(-3.4028234663852886e+38) + __inclusive_maximum = decimal.Decimal(3.4028234663852886e+38) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type float at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Float32Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + + +class Float32Schema( + Float32Base, + NumberSchema +): + + @classmethod + def from_openapi_data_oapg(cls, arg: float, _configuration: typing.Optional[Configuration] = None): + return super().from_openapi_data_oapg(arg, _configuration=_configuration) + + +class Float64Base: + __inclusive_minimum = decimal.Decimal(-1.7976931348623157E+308) + __inclusive_maximum = decimal.Decimal(1.7976931348623157E+308) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type double at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Float64Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) + +class Float64Schema( + Float64Base, + NumberSchema +): + + @classmethod + def from_openapi_data_oapg(cls, arg: float, _configuration: typing.Optional[Configuration] = None): + # todo check format + return super().from_openapi_data_oapg(arg, _configuration=_configuration) + + +class StrSchema( + StrBase, + Schema, + StrMixin +): + \\"\\"\\" + date + datetime string types must inherit from this class + That is because one can validate a str payload as both: + - type: string (format unset) + - type: string, format: date + \\"\\"\\" + + @classmethod + def from_openapi_data_oapg(cls, arg: str, _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': + return super().from_openapi_data_oapg(arg, _configuration=_configuration) + + def __new__(cls, _arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) + + +class UUIDSchema(UUIDBase, StrSchema): + + def __new__(cls, _arg: typing.Union[str, uuid.UUID], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) + + +class DateSchema(DateBase, StrSchema): + + def __new__(cls, _arg: typing.Union[str, date], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) + + +class DateTimeSchema(DateTimeBase, StrSchema): + + def __new__(cls, _arg: typing.Union[str, datetime], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) + + +class DecimalSchema(DecimalBase, StrSchema): + + def __new__(cls, _arg: str, **kwargs: Configuration): + \\"\\"\\" + Note: Decimals may not be passed in because cast_to_allowed_types is only invoked once for payloads + which can be simple (str) or complex (dicts or lists with nested values) + Because casting is only done once and recursively casts all values prior to validation then for a potential + client side Decimal input if Decimal was accepted as an input in DecimalSchema then one would not know + if one was using it for a StrSchema (where it should be cast to str) or one is using it for NumberSchema + where it should stay as Decimal. + \\"\\"\\" + return super().__new__(cls, _arg, **kwargs) + + +class BytesSchema( + Schema, + BytesMixin +): + \\"\\"\\" + this class will subclass bytes and is immutable + \\"\\"\\" + def __new__(cls, _arg: bytes, **kwargs: Configuration): + return super(Schema, cls).__new__(cls, _arg) + + +class FileSchema( + Schema, + FileMixin +): + \\"\\"\\" + This class is NOT immutable + Dynamic classes are built using it for example when AnyType allows in binary data + Al other schema classes ARE immutable + If one wanted to make this immutable one could make this a DictSchema with required properties: + - data = BytesSchema (which would be an immutable bytes based schema) + - file_name = StrSchema + and cast_to_allowed_types would convert bytes and file instances into dicts containing data + file_name + The downside would be that data would be stored in memory which one may not want to do for very large files + + The developer is responsible for closing this file and deleting it + + This class was kept as mutable: + - to allow file reading and writing to disk + - to be able to preserve file name info + \\"\\"\\" + + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: Configuration): + return super(Schema, cls).__new__(cls, _arg) + + +class BinaryBase: + pass + + +class BinarySchema( + ComposedBase, + BinaryBase, + Schema, + BinaryMixin +): + class MetaOapg: + @staticmethod + def one_of(): + return [ + BytesSchema, + FileSchema, + ] + + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: Configuration): + return super().__new__(cls, _arg) + + +class BoolSchema( + BoolBase, + Schema, + BoolMixin +): + + @classmethod + def from_openapi_data_oapg(cls, arg: bool, _configuration: typing.Optional[Configuration] = None): + return super().from_openapi_data_oapg(arg, _configuration=_configuration) + + def __new__(cls, _arg: bool, **kwargs: ValidationMetadata): + return super().__new__(cls, _arg, **kwargs) + + +class AnyTypeSchema( + DictBase, + ListBase, + NumberBase, + StrBase, + BoolBase, + NoneBase, + Schema, + NoneFrozenDictTupleStrDecimalBoolFileBytesMixin +): + # Python representation of a schema defined as true or {} + pass + + +class UnsetAnyTypeSchema(AnyTypeSchema): + # Used when additionalProperties/items was not explicitly defined and a defining schema is needed + pass + + +class NotAnyTypeSchema( + ComposedSchema, +): + \\"\\"\\" + Python representation of a schema defined as false or {'not': {}} + Does not allow inputs in of AnyType + Note: validations on this class are never run because the code knows that no inputs will ever validate + \\"\\"\\" + + class MetaOapg: + not_schema = AnyTypeSchema + + def __new__( + cls, + *_args, + _configuration: typing.Optional[Configuration] = None, + ) -> 'NotAnyTypeSchema': + return super().__new__( + cls, + *_args, + _configuration=_configuration, + ) + + +class DictSchema( + DictBase, + Schema, + FrozenDictMixin +): + @classmethod + def from_openapi_data_oapg(cls, arg: typing.Dict[str, typing.Any], _configuration: typing.Optional[Configuration] = None): + return super().from_openapi_data_oapg(arg, _configuration=_configuration) + + def __new__(cls, *_args: typing.Union[dict, frozendict.frozendict], **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): + return super().__new__(cls, *_args, **kwargs) + + +schema_type_classes = {NoneSchema, DictSchema, ListSchema, NumberSchema, StrSchema, BoolSchema, AnyTypeSchema} + + +@functools.lru_cache() +def get_new_class( + class_name: str, + bases: typing.Tuple[typing.Type[typing.Union[Schema, typing.Any]], ...] +) -> typing.Type[Schema]: + \\"\\"\\" + Returns a new class that is made with the subclass bases + \\"\\"\\" + new_cls: typing.Type[Schema] = type(class_name, bases, {}) + return new_cls + + +LOG_CACHE_USAGE = False + + +def log_cache_usage(cache_fn): + if LOG_CACHE_USAGE: + print(cache_fn.__name__, cache_fn.cache_info())", + "test/test_models/__init__.py": "", + "test/test_paths/__init__.py": "import json +import typing + +import urllib3 +from urllib3._collections import HTTPHeaderDict + + +class ApiTestMixin: + json_content_type = 'application/json' + user_agent = 'OpenAPI-Generator/1.0.0/python' + + @classmethod + def assert_pool_manager_request_called_with( + cls, + mock_request, + url: str, + method: str = 'POST', + body: typing.Optional[bytes] = None, + content_type: typing.Optional[str] = None, + accept_content_type: typing.Optional[str] = None, + stream: bool = False, + ): + headers = { + 'User-Agent': cls.user_agent + } + if accept_content_type: + headers['Accept'] = accept_content_type + if content_type: + headers['Content-Type'] = content_type + kwargs = dict( + headers=HTTPHeaderDict(headers), + preload_content=not stream, + timeout=None, + ) + if content_type and method != 'GET': + kwargs['body'] = body + mock_request.assert_called_with( + method, + url, + **kwargs + ) + + @staticmethod + def headers_for_content_type(content_type: str) -> typing.Dict[str, str]: + return {'content-type': content_type} + + @classmethod + def response( + cls, + body: typing.Union[str, bytes], + status: int = 200, + content_type: str = json_content_type, + headers: typing.Optional[typing.Dict[str, str]] = None, + preload_content: bool = True + ) -> urllib3.HTTPResponse: + if headers is None: + headers = {} + headers.update(cls.headers_for_content_type(content_type)) + return urllib3.HTTPResponse( + body, + headers=headers, + status=status, + preload_content=preload_content + ) + + @staticmethod + def json_bytes(in_data: typing.Any) -> bytes: + return json.dumps(in_data, separators=(\\",\\", \\":\\"), ensure_ascii=False).encode('utf-8') +", + "test/test_paths/test_both/__init__.py": "", + "test/test_paths/test_both/test_get.py": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +import unittest +from unittest.mock import patch + +import urllib3 + +import test +from test.paths.both import get # noqa: E501 +from test import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestBoth(ApiTestMixin, unittest.TestCase): + \\"\\"\\" + Both unit test stubs + \\"\\"\\" + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = get.ApiForget(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + +if __name__ == '__main__': + unittest.main() +", + "test/test_paths/test_neither/__init__.py": "", + "test/test_paths/test_neither/test_get.py": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +import unittest +from unittest.mock import patch + +import urllib3 + +import test +from test.paths.neither import get # noqa: E501 +from test import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestNeither(ApiTestMixin, unittest.TestCase): + \\"\\"\\" + Neither unit test stubs + \\"\\"\\" + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = get.ApiForget(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + +if __name__ == '__main__': + unittest.main() +", + "test/test_paths/test_tag1/__init__.py": "", + "test/test_paths/test_tag1/test_get.py": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +import unittest +from unittest.mock import patch + +import urllib3 + +import test +from test.paths.tag1 import get # noqa: E501 +from test import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestTag1(ApiTestMixin, unittest.TestCase): + \\"\\"\\" + Tag1 unit test stubs + \\"\\"\\" + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = get.ApiForget(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + +if __name__ == '__main__': + unittest.main() +", + "test/test_paths/test_tag2/__init__.py": "", + "test/test_paths/test_tag2/test_get.py": "# coding: utf-8 + +\\"\\"\\" + + + Generated by: https://openapi-generator.tech +\\"\\"\\" + +import unittest +from unittest.mock import patch + +import urllib3 + +import test +from test.paths.tag2 import get # noqa: E501 +from test import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestTag2(ApiTestMixin, unittest.TestCase): + \\"\\"\\" + Tag2 unit test stubs + \\"\\"\\" + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = get.ApiForget(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + +if __name__ == '__main__': + unittest.main() +", + "tests/__init__.py": "", + "tests/test_example.py": "import pytest + +from test.example import hello + +@pytest.mark.parametrize( + (\\"name\\", \\"expected\\"), + [ + (\\"A. Musing\\", \\"Hello A. Musing!\\"), + (\\"traveler\\", \\"Hello traveler!\\"), + (\\"projen developer\\", \\"Hello projen developer!\\"), + ], +) +def test_hello(name, expected): + \\"\\"\\"Example test with parametrization.\\"\\"\\" + assert hello(name) == expected +", + "tox.ini": "[tox] +envlist = py37 + +[testenv] +passenv = PYTHON_VERSION +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + pytest --cov=test +", +} +`; + +exports[`Generated Python Client Code Unit Tests Single 1`] = ` +Object { + ".gitattributes": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +/.gitattributes linguist-generated +/.github/workflows/pull-request-lint.yml linguist-generated +/.gitignore linguist-generated +/.projen/** linguist-generated +/.projen/deps.json linguist-generated +/.projen/files.json linguist-generated +/.projen/tasks.json linguist-generated +/requirements-dev.txt linguist-generated +/requirements.txt linguist-generated", + ".github/workflows/pull-request-lint.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +name: pull-request-lint +on: + pull_request_target: + types: + - labeled + - opened + - synchronize + - reopened + - ready_for_review + - edited +jobs: + validate: + name: Validate PR title + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: amannn/action-semantic-pull-request@v5.0.2 + env: + GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + with: + types: |- + feat + fix + chore + requireScope: false +", + ".gitignore": "# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt +dev-requirements.txt.log + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.venv/ +.python-version +.pytest_cache + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints +", + ".gitlab-ci.yml": "# ref: https://docs.gitlab.com/ee/ci/README.html + +stages: + - test + +.tests: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + - pytest --cov=test + +test-3.5: + extends: .tests + image: python:3.5-alpine +test-3.6: + extends: .tests + image: python:3.6-alpine +test-3.7: + extends: .tests + image: python:3.7-alpine +test-3.8: + extends: .tests + image: python:3.8-alpine +", + ".openapi-generator-ignore": "# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md +", + ".openapi-generator/FILES": ".gitignore +.gitlab-ci.yml +.openapi-generator-ignore +.travis.yml +README.md +docs/apis/tags/DefaultApi.md +docs/models/ApiError.md +docs/models/TestRequest.md +docs/models/TestResponse.md +git_push.sh +requirements.txt +setup.cfg +setup.py +test-requirements.txt +test/__init__.py +test/__init__.py +test/api_client.py +test/apis/__init__.py +test/apis/tags/default_api.py +test/apis/tags/default_api_operation_config.py +test/configuration.py +test/exceptions.py +test/model/__init__.py +test/model/api_error.py +test/model/api_error.pyi +test/model/test_request.py +test/model/test_request.pyi +test/model/test_response.py +test/model/test_response.pyi +test/models/__init__.py +test/rest.py +test/schemas.py +test/test_models/__init__.py +test/test_models/test_api_error.py +test/test_models/test_test_request.py +test/test_models/test_test_response.py +tox.ini +", + ".openapi-generator/VERSION": "6.3.0", + ".projen/deps.json": Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "dependencies": Array [ + Object { + "name": "projen", + "type": "devenv", + "version": "99.99.99", + }, + Object { + "name": "pytest", + "type": "test", + "version": "6.2.1", + }, + ], + }, + ".projen/files.json": Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "files": Array [ + ".gitattributes", + ".github/workflows/pull-request-lint.yml", + ".gitignore", + ".projen/deps.json", + ".projen/files.json", + ".projen/tasks.json", + "requirements-dev.txt", + "requirements.txt", + ], + }, + ".projen/tasks.json": Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "env": Object { + "PATH": "$(echo $PWD/.env/bin:$PATH)", + "VIRTUAL_ENV": "$(echo $PWD/.env)", + }, + "tasks": Object { + "build": Object { + "description": "Full release build", + "name": "build", + "steps": Array [ + Object { + "spawn": "default", + }, + Object { + "spawn": "pre-compile", + }, + Object { + "spawn": "compile", + }, + Object { + "spawn": "post-compile", + }, + Object { + "spawn": "test", + }, + Object { + "spawn": "package", + }, + ], + }, + "clobber": Object { + "condition": "git diff --exit-code > /dev/null", + "description": "hard resets to HEAD of origin and cleans the local repo", + "env": Object { + "BRANCH": "$(git branch --show-current)", + }, + "name": "clobber", + "steps": Array [ + Object { + "exec": "git checkout -b scratch", + "name": "save current HEAD in \\"scratch\\" branch", + }, + Object { + "exec": "git checkout $BRANCH", + }, + Object { + "exec": "git fetch origin", + "name": "fetch latest changes from origin", + }, + Object { + "exec": "git reset --hard origin/$BRANCH", + "name": "hard reset to origin commit", + }, + Object { + "exec": "git clean -fdx", + "name": "clean all untracked files", + }, + Object { + "say": "ready to rock! (unpushed commits are under the \\"scratch\\" branch)", + }, + ], + }, + "compile": Object { + "description": "Only compile", + "name": "compile", + }, + "default": Object { + "description": "Synthesize project files", + "name": "default", + "steps": Array [ + Object { + "exec": "python .projenrc.py", + }, + ], + }, + "eject": Object { + "description": "Remove projen from the project", + "env": Object { + "PROJEN_EJECTING": "true", + }, + "name": "eject", + "steps": Array [ + Object { + "spawn": "default", + }, + ], + }, + "install": Object { + "description": "Install and upgrade dependencies", + "name": "install", + "steps": Array [ + Object { + "exec": "pip install --upgrade pip", + }, + Object { + "exec": "pip install -r requirements.txt", + }, + Object { + "exec": "pip install -r requirements-dev.txt", + }, + ], + }, + "package": Object { + "description": "Creates the distribution package", + "name": "package", + }, + "post-compile": Object { + "description": "Runs after successful compilation", + "name": "post-compile", + }, + "pre-compile": Object { + "description": "Prepare the project for compilation", + "name": "pre-compile", + }, + "test": Object { + "description": "Run tests", + "name": "test", + "steps": Array [ + Object { + "exec": "pytest", + }, + ], + }, + }, + }, + ".travis.yml": "# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - \\"3.5\\" + - \\"3.6\\" + - \\"3.7\\" + - \\"3.8\\" +# command to install dependencies +install: + - \\"pip install -r requirements.txt\\" + - \\"pip install -r test-requirements.txt\\" +# command to run tests +script: pytest --cov=test +", + "README.md": "# test +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: 1.0.0 +- Package version: 1.0.0 +- Build package: org.openapitools.codegen.languages.PythonClientCodegen + +## Requirements. + +Python >=3.7 + +## Migration from other generators like python and python-legacy + +### Changes +1. This generator uses spec case for all (object) property names and parameter names. + - So if the spec has a property name like camelCase, it will use camelCase rather than camel_case + - So you will need to update how you input and read properties to use spec case +2. Endpoint parameters are stored in dictionaries to prevent collisions (explanation below) + - So you will need to update how you pass data in to endpoints +3. Endpoint responses now include the original response, the deserialized response body, and (todo)the deserialized headers + - So you will need to update your code to use response.body to access deserialized data +4. All validated data is instantiated in an instance that subclasses all validated Schema classes and Decimal/str/list/tuple/frozendict/NoneClass/BoolClass/bytes/io.FileIO + - This means that you can use isinstance to check if a payload validated against a schema class + - This means that no data will be of type None/True/False + - ingested None will subclass NoneClass + - ingested True will subclass BoolClass + - ingested False will subclass BoolClass + - So if you need to check is True/False/None, instead use instance.is_true_oapg()/.is_false_oapg()/.is_none_oapg() +5. All validated class instances are immutable except for ones based on io.File + - This is because if properties were changed after validation, that validation would no longer apply + - So no changing values or property values after a class has been instantiated +6. String + Number types with formats + - String type data is stored as a string and if you need to access types based on its format like date, + date-time, uuid, number etc then you will need to use accessor functions on the instance + - type string + format: See .as_date_oapg, .as_datetime_oapg, .as_decimal_oapg, .as_uuid_oapg + - type number + format: See .as_float_oapg, .as_int_oapg + - this was done because openapi/json-schema defines constraints. string data may be type string with no format + keyword in one schema, and include a format constraint in another schema + - So if you need to access a string format based type, use as_date_oapg/as_datetime_oapg/as_decimal_oapg/as_uuid_oapg + - So if you need to access a number format based type, use as_int_oapg/as_float_oapg +7. Property access on AnyType(type unset) or object(dict) schemas + - Only required keys with valid python names are properties like .someProp and have type hints + - All optional keys may not exist, so properties are not defined for them + - One can access optional values with dict_instance['optionalProp'] and KeyError will be raised if it does not exist + - Use get_item_oapg if you need a way to always get a value whether or not the key exists + - If the key does not exist, schemas.unset is returned from calling dict_instance.get_item_oapg('optionalProp') + - All required and optional keys have type hints for this method, and @typing.overload is used + - A type hint is also generated for additionalProperties accessed using this method + - So you will need to update you code to use some_instance['optionalProp'] to access optional property + and additionalProperty values +8. The location of the api classes has changed + - Api classes are located in your_package.apis.tags.some_api + - This change was made to eliminate redundant code generation + - Legacy generators generated the same endpoint twice if it had > 1 tag on it + - This generator defines an endpoint in one class, then inherits that class to generate + apis by tags and by paths + - This change reduces code and allows quicker run time if you use the path apis + - path apis are at your_package.apis.paths.some_path + - Those apis will only load their needed models, which is less to load than all of the resources needed in a tag api + - So you will need to update your import paths to the api classes + +### Why are Oapg and _oapg used in class and method names? +Classes can have arbitrarily named properties set on them +Endpoints can have arbitrary operationId method names set +For those reasons, I use the prefix Oapg and _oapg to greatly reduce the likelihood of collisions +on protected + public classes/methods. +oapg stands for OpenApi Python Generator. + +### Object property spec case +This was done because when payloads are ingested, they can be validated against N number of schemas. +If the input signature used a different property name then that has mutated the payload. +So SchemaA and SchemaB must both see the camelCase spec named variable. +Also it is possible to send in two properties, named camelCase and camel_case in the same payload. +That use case should be support so spec case is used. + +### Parameter spec case +Parameters can be included in different locations including: +- query +- path +- header +- cookie + +Any of those parameters could use the same parameter names, so if every parameter +was included as an endpoint parameter in a function signature, they would collide. +For that reason, each of those inputs have been separated out into separate typed dictionaries: +- query_params +- path_params +- header_params +- cookie_params + +So when updating your code, you will need to pass endpoint parameters in using those +dictionaries. + +### Endpoint responses +Endpoint responses have been enriched to now include more information. +Any response reom an endpoint will now include the following properties: +response: urllib3.HTTPResponse +body: typing.Union[Unset, Schema] +headers: typing.Union[Unset, TODO] +Note: response header deserialization has not yet been added + + +## Installation & Usage +### pip install + +If the python package is hosted on a repository, you can install directly using: + +\`\`\`sh +pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git +\`\`\` +(you may need to run \`pip\` with root permission: \`sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git\`) + +Then import the package: +\`\`\`python +import test +\`\`\` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +\`\`\`sh +python setup.py install --user +\`\`\` +(or \`sudo python setup.py install\` to install the package for all users) + +Then import the package: +\`\`\`python +import test +\`\`\` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +\`\`\`python + +import time +import test +from pprint import pprint +from test.apis.tags import default_api +from test.model.api_error import ApiError +from test.model.test_request import TestRequest +from test.model.test_response import TestResponse +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = test.Configuration( + host = \\"http://localhost\\" +) + + +# Enter a context with an instance of the API client +with test.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = default_api.DefaultApi(api_client) + body = None # bool, date, datetime, dict, float, int, list, str, none_type | (optional) + + try: + api_response = api_instance.any_request_response(body=body) + pprint(api_response) + except test.ApiException as e: + print(\\"Exception when calling DefaultApi->any_request_response: %s\\\\n\\" % e) +\`\`\` + +## Documentation for API Endpoints + +All URIs are relative to *http://localhost* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*DefaultApi* | [**any_request_response**](docs/apis/tags/DefaultApi.md#any_request_response) | **put** /any-request-response | +*DefaultApi* | [**empty**](docs/apis/tags/DefaultApi.md#empty) | **put** /empty-response | +*DefaultApi* | [**media_types**](docs/apis/tags/DefaultApi.md#media_types) | **post** /different-media-type | +*DefaultApi* | [**operation_one**](docs/apis/tags/DefaultApi.md#operation_one) | **post** /path/{pathParam} | +*DefaultApi* | [**without_operation_id_delete**](docs/apis/tags/DefaultApi.md#without_operation_id_delete) | **delete** /without-operation-id | + +## Documentation For Models + + - [ApiError](docs/models/ApiError.md) + - [TestRequest](docs/models/TestRequest.md) + - [TestResponse](docs/models/TestResponse.md) + +## Documentation For Authorization + + All endpoints do not require authorization. + +## Author + + + +## Notes for Large OpenAPI documents +If the OpenAPI document is large, imports in test.apis and test.models may fail with a +RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions: + +Solution 1: +Use specific imports for apis and models like: +- \`from test.apis.default_api import DefaultApi\` +- \`from test.model.pet import Pet\` + +Solution 1: +Before importing the package, adjust the maximum recursion limit as shown below: +\`\`\` +import sys +sys.setrecursionlimit(1500) +import test +from test.apis import * +from test.models import * +\`\`\` +", + "docs/apis/tags/DefaultApi.md": " +# test.apis.tags.default_api.DefaultApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**any_request_response**](#any_request_response) | **put** /any-request-response | +[**empty**](#empty) | **put** /empty-response | +[**media_types**](#media_types) | **post** /different-media-type | +[**operation_one**](#operation_one) | **post** /path/{pathParam} | +[**without_operation_id_delete**](#without_operation_id_delete) | **delete** /without-operation-id | + +# **any_request_response** + +> bool, date, datetime, dict, float, int, list, str, none_type any_request_response() + + + +### Example + +\`\`\`python +import test +from test.apis.tags import default_api +from pprint import pprint +# Defining the host is optional and defaults to http://localhost +# See configuration.py for a list of all supported configuration parameters. +configuration = test.Configuration( + host = \\"http://localhost\\" +) + +# Enter a context with an instance of the API client +with test.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = default_api.DefaultApi(api_client) + + # example passing only optional values + body = None + try: + api_response = api_instance.any_request_response( + body=body, + ) + pprint(api_response) + except test.ApiException as e: + print(\\"Exception when calling DefaultApi->any_request_response: %s\\\\n\\" % e) +\`\`\` +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +body | typing.Union[SchemaForRequestBodyApplicationJson, Unset] | optional, default is unset | +content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body +accept_content_types | typing.Tuple[str] | default is ('application/json', ) | Tells the server the content type(s) that are accepted by the client +stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file timeout | typing.Optional[typing.Union[int, typing.Tuple]] | default is None | the timeout used by the rest client skip_deserialization | bool | default is False | when True, headers and body will be unset and an instance of api_client.ApiResponseWithoutDeserialization will be returned ### body -#### SchemaForRequestBodyApplicationJson +# SchemaForRequestBodyApplicationJson -Type | Description | Notes -------------- | ------------- | ------------- -typing.Union[dict, frozendict, str, date, datetime, int, float, bool, Decimal, None, list, tuple, bytes] | | +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, | frozendict.frozendict, str, decimal.Decimal, BoolClass, NoneClass, tuple, bytes, FileIO | | ### Return Types, Responses Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -200 | ApiResponseFor200 | Any response +200 | [ApiResponseFor200](#any_request_response.ApiResponseFor200) | Any response -#### ApiResponseFor200 +#### any_request_response.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | | headers | Unset | headers were not defined | -#### SchemaFor200ResponseBodyApplicationJson - -Type | Description | Notes -------------- | ------------- | ------------- -typing.Union[dict, frozendict, str, date, datetime, int, float, bool, Decimal, None, list, tuple, bytes] | | - +# SchemaFor200ResponseBodyApplicationJson -**bool, date, datetime, dict, float, int, list, str, none_type** +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, | frozendict.frozendict, str, decimal.Decimal, BoolClass, NoneClass, tuple, bytes, FileIO | | ### Authorization @@ -7751,18 +16794,15 @@ This endpoint does not need any parameter. Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -204 | ApiResponseFor204 | No response body! +204 | [ApiResponseFor204](#empty.ApiResponseFor204) | No response body! -#### ApiResponseFor204 +#### empty.ApiResponseFor204 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | Unset | body was not defined | headers | Unset | headers were not defined | - -void (empty response body) - ### Authorization No authorization required @@ -7815,34 +16855,33 @@ skip_deserialization | bool | default is False | when True, headers and body wil ### body -#### SchemaForRequestBodyApplicationPdf +# SchemaForRequestBodyApplicationPdf -Type | Description | Notes -------------- | ------------- | ------------- -**file_type** | | +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +bytes, io.FileIO, io.BufferedReader, | bytes, FileIO, | | ### Return Types, Responses Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -200 | ApiResponseFor200 | Success +200 | [ApiResponseFor200](#media_types.ApiResponseFor200) | Success -#### ApiResponseFor200 +#### media_types.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | typing.Union[SchemaFor200ResponseBodyApplicationXMpegurl, ] | | headers | Unset | headers were not defined | -#### SchemaFor200ResponseBodyApplicationXMpegurl - -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | - +# SchemaFor200ResponseBodyApplicationXMpegurl -**str** +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +str, | str, | | ### Authorization @@ -7940,10 +16979,10 @@ skip_deserialization | bool | default is False | when True, headers and body wil ### body -#### SchemaForRequestBodyApplicationJson +# SchemaForRequestBodyApplicationJson Type | Description | Notes ------------- | ------------- | ------------- -[**TestRequest**](TestRequest.md) | | +[**TestRequest**](../../models/TestRequest.md) | | ### query_params @@ -7957,29 +16996,38 @@ param3 | Param3Schema | | param4 | Param4Schema | | optional -#### Param1Schema +# Param1Schema -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +str, | str, | | -#### Param2Schema +# Param2Schema -Type | Description | Notes -------------- | ------------- | ------------- -**[str]** | | +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +list, tuple, | tuple, | | -#### Param3Schema +### Tuple Items +Class Name | Input Type | Accessed Type | Description | Notes +------------- | ------------- | ------------- | ------------- | ------------- +items | str, | str, | | -Type | Description | Notes -------------- | ------------- | ------------- -**int, float** | | +# Param3Schema + +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +decimal.Decimal, int, float, | decimal.Decimal, | | -#### Param4Schema +# Param4Schema -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +str, | str, | | ### path_params #### RequestPathParams @@ -7988,49 +17036,47 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- pathParam | PathParamSchema | | -#### PathParamSchema +# PathParamSchema -Type | Description | Notes -------------- | ------------- | ------------- -**str** | | +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +str, | str, | | ### Return Types, Responses Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -200 | ApiResponseFor200 | Successful response -400 | ApiResponseFor400 | Error response +200 | [ApiResponseFor200](#operation_one.ApiResponseFor200) | Successful response +400 | [ApiResponseFor400](#operation_one.ApiResponseFor400) | Error response -#### ApiResponseFor200 +#### operation_one.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | | headers | Unset | headers were not defined | -#### SchemaFor200ResponseBodyApplicationJson +# SchemaFor200ResponseBodyApplicationJson Type | Description | Notes ------------- | ------------- | ------------- -[**TestResponse**](TestResponse.md) | | +[**TestResponse**](../../models/TestResponse.md) | | -#### ApiResponseFor400 +#### operation_one.ApiResponseFor400 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | typing.Union[SchemaFor400ResponseBodyApplicationJson, ] | | headers | Unset | headers were not defined | -#### SchemaFor400ResponseBodyApplicationJson +# SchemaFor400ResponseBodyApplicationJson Type | Description | Notes ------------- | ------------- | ------------- -[**ApiError**](ApiError.md) | | - +[**ApiError**](../../models/ApiError.md) | | -[**TestResponse**](TestResponse.md) - ### Authorization No authorization required @@ -8076,24 +17122,21 @@ This endpoint does not need any parameter. Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -200 | ApiResponseFor200 | Successful response +200 | [ApiResponseFor200](#without_operation_id_delete.ApiResponseFor200) | Successful response -#### ApiResponseFor200 +#### without_operation_id_delete.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | | headers | Unset | headers were not defined | -#### SchemaFor200ResponseBodyApplicationJson +# SchemaFor200ResponseBodyApplicationJson Type | Description | Notes ------------- | ------------- | ------------- -[**TestResponse**](TestResponse.md) | | - +[**TestResponse**](../../models/TestResponse.md) | | -[**TestResponse**](TestResponse.md) - ### Authorization No authorization required @@ -8103,33 +17146,74 @@ No authorization required ", "docs/models/ApiError.md": "# test.model.api_error.ApiError -#### Properties -Name | Type | Description | Notes +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +dict, frozendict.frozendict, | frozendict.frozendict, | | + +### Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**errorMessage** | str, | str, | | +**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + +", + "docs/models/TestRequest.md": "# test.model.test_request.TestRequest + +## Model Type Info +Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**errorMessage** | **str** | | -**any string name** | dict, frozendict, str, date, datetime, int, float, bool, Decimal, None, list, tuple, bytes | any string name can be used but the value must be the correct type | [optional] +dict, frozendict.frozendict, | frozendict.frozendict, | | + +### Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**myInput** | decimal.Decimal, int, float, | decimal.Decimal, | | [optional] +**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) -", - "docs/models/TestRequest.md": "# test.model.test_request.TestRequest +", + "docs/models/TestResponse.md": "# test.model.test_response.TestResponse + +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +dict, frozendict.frozendict, | frozendict.frozendict, | | + +### Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**[messages](#messages)** | list, tuple, | tuple, | | +**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional] + +# messages -#### Properties -Name | Type | Description | Notes +## Model Type Info +Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**myInput** | **int, float** | | [optional] -**any string name** | dict, frozendict, str, date, datetime, int, float, bool, Decimal, None, list, tuple, bytes | any string name can be used but the value must be the correct type | [optional] +list, tuple, | tuple, | | -[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) +### Tuple Items +Class Name | Input Type | Accessed Type | Description | Notes +------------- | ------------- | ------------- | ------------- | ------------- +[items](#items) | dict, frozendict.frozendict, | frozendict.frozendict, | | -", - "docs/models/TestResponse.md": "# test.model.test_response.TestResponse +# items -#### Properties -Name | Type | Description | Notes +## Model Type Info +Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**messages** | **[{str: (bool, date, datetime, dict, float, int, list, str, none_type)}]** | | -**any string name** | dict, frozendict, str, date, datetime, int, float, bool, Decimal, None, list, tuple, bytes | any string name can be used but the value must be the correct type | [optional] +dict, frozendict.frozendict, | frozendict.frozendict, | | + +### Dictionary Keys +Key | Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- | ------------- +**id** | decimal.Decimal, int, | decimal.Decimal, | | +**message** | str, | str, | | [optional] +**any_string_name** | dict, frozendict.frozendict, str, date, datetime, int, float, bool, decimal.Decimal, None, list, tuple, bytes, io.FileIO, io.BufferedReader | frozendict.frozendict, str, BoolClass, decimal.Decimal, NoneClass, tuple, bytes, FileIO | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) @@ -8137,7 +17221,7 @@ Name | Type | Description | Notes "git_push.sh": "#!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl \\"minor update\\" \\"gitlab.com\\" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl \\"minor update\\" \\"gitlab.com\\" git_user_id=$1 git_repo_id=$2 @@ -8196,11 +17280,12 @@ git push origin master 2>&1 | grep -v 'To https' "requirements-dev.txt": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". projen==99.99.99 ", - "requirements.txt": "certifi >= 14.05.14 -frozendict >= 2.0.3 -python_dateutil >= 2.5.3 + "requirements.txt": "certifi >= 14.5.14 +frozendict ~= 2.3.4 +python-dateutil ~= 2.7.0 setuptools >= 21.0.0 -urllib3 >= 1.15.1 +typing_extensions ~= 4.3.0 +urllib3 ~= 1.26.7 ", "setup.cfg": "[flake8] max-line-length=99 @@ -8228,10 +17313,12 @@ VERSION = \\"1.0.0\\" # http://pypi.python.org/pypi/setuptools REQUIRES = [ - \\"urllib3 >= 1.15\\", - \\"certifi\\", - \\"python-dateutil\\", - \\"frozendict >= 2.0.3\\", + \\"certifi >= 14.5.14\\", + \\"frozendict ~= 2.3.4\\", + \\"python-dateutil ~= 2.7.0\\", + \\"setuptools >= 21.0.0\\", + \\"typing_extensions ~= 4.3.0\\", + \\"urllib3 ~= 1.26.7\\", ] setup( @@ -8242,7 +17329,7 @@ setup( author_email=\\"team@openapitools.org\\", url=\\"\\", keywords=[\\"OpenAPI\\", \\"OpenAPI-Generator\\", \\"Example API\\"], - python_requires=\\">=3.9\\", + python_requires=\\">=3.7\\", install_requires=REQUIRES, packages=find_packages(exclude=[\\"test\\", \\"tests\\"]), include_package_data=True, @@ -8284,9 +17371,10 @@ from multiprocessing.pool import ThreadPool import re import tempfile import typing +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict -from urllib.parse import quote +from urllib.parse import urlparse, quote from urllib3.fields import RequestField as RequestFieldBase import frozendict @@ -8316,6 +17404,8 @@ class RequestField(RequestFieldBase): class JSONEncoder(json.JSONEncoder): + compact_separators = (',', ':') + def default(self, obj): if isinstance(obj, str): return str(obj) @@ -8558,7 +17648,7 @@ class StyleFormSerializer(ParameterSerializerBase): prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None ) -> str: if prefix_separator_iterator is None: - prefix_separator_iterator = PrefixSeparatorIterator('?', '&') + prefix_separator_iterator = PrefixSeparatorIterator('', '&') return self._ref6570_expansion( variable_name=name, in_data=in_data, @@ -8587,8 +17677,25 @@ class StyleSimpleSerializer(ParameterSerializerBase): ) +class JSONDetector: + \\"\\"\\" + Works for: + application/json + application/json; charset=UTF-8 + application/json-patch+json + application/geo+json + \\"\\"\\" + __json_content_type_pattern = re.compile(\\"application/[^+]*[+]?(json);?.*\\") + + @classmethod + def _content_type_is_json(cls, content_type: str) -> bool: + if cls.__json_content_type_pattern.match(content_type): + return True + return False + + @dataclass -class ParameterBase: +class ParameterBase(JSONDetector): name: str in_type: ParameterInType required: bool @@ -8615,7 +17722,6 @@ class ParameterBase: } __disallowed_header_names = {'Accept', 'Content-Type', 'Authorization'} _json_encoder = JSONEncoder() - _json_content_type = 'application/json' @classmethod def __verify_style_to_in_type(cls, style: typing.Optional[ParameterStyle], in_type: ParameterInType): @@ -8662,8 +17768,11 @@ class ParameterBase: def _serialize_json( self, - in_data: typing.Union[None, int, float, str, bool, dict, list] + in_data: typing.Union[None, int, float, str, bool, dict, list], + eliminate_whitespace: bool = False ) -> str: + if eliminate_whitespace: + return json.dumps(in_data, separators=self._json_encoder.compact_separators) return json.dumps(in_data) @@ -8758,7 +17867,7 @@ class PathParameter(ParameterBase, StyleSimpleSerializer): for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: + if self._content_type_is_json(content_type): value = self._serialize_json(cast_in_data) return self._to_dict(self.name, value) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -8776,7 +17885,7 @@ class QueryParameter(ParameterBase, StyleFormSerializer): schema: typing.Optional[typing.Type[Schema]] = None, content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None ): - used_style = ParameterStyle.FORM if style is None and content is None and schema else style + used_style = ParameterStyle.FORM if style is None else style used_explode = self._get_default_explode(used_style) if explode is None else explode super().__init__( @@ -8839,8 +17948,6 @@ class QueryParameter(ParameterBase, StyleFormSerializer): return self._to_dict(self.name, value) def get_prefix_separator_iterator(self) -> typing.Optional[PrefixSeparatorIterator]: - if not self.schema: - return None if self.style is ParameterStyle.FORM: return PrefixSeparatorIterator('?', '&') elif self.style is ParameterStyle.SPACE_DELIMITED: @@ -8879,12 +17986,17 @@ class QueryParameter(ParameterBase, StyleFormSerializer): elif self.style is ParameterStyle.PIPE_DELIMITED: return self.__serialize_pipe_delimited(cast_in_data, prefix_separator_iterator) # self.content will be length one + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: - value = self._serialize_json(cast_in_data) - return self._to_dict(self.name, value) + if self._content_type_is_json(content_type): + value = self._serialize_json(cast_in_data, eliminate_whitespace=True) + return self._to_dict( + self.name, + next(prefix_separator_iterator) + self.name + '=' + quote(value) + ) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -8943,7 +18055,7 @@ class CookieParameter(ParameterBase, StyleFormSerializer): for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: + if self._content_type_is_json(content_type): value = self._serialize_json(cast_in_data) return self._to_dict(self.name, value) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -8972,7 +18084,7 @@ class HeaderParameter(ParameterBase, StyleSimpleSerializer): ) @staticmethod - def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict[str, str]: + def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict: data = tuple(t for t in in_data if t) headers = HTTPHeaderDict() if not data: @@ -8984,7 +18096,7 @@ class HeaderParameter(ParameterBase, StyleSimpleSerializer): self, in_data: typing.Union[ Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict.frozendict] - ) -> HTTPHeaderDict[str, str]: + ) -> HTTPHeaderDict: if self.schema: cast_in_data = self.schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) @@ -9000,7 +18112,7 @@ class HeaderParameter(ParameterBase, StyleSimpleSerializer): for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: + if self._content_type_is_json(content_type): value = self._serialize_json(cast_in_data) return self.__to_headers(((self.name, value),)) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -9039,14 +18151,14 @@ class MediaType: @dataclass class ApiResponse: response: urllib3.HTTPResponse - body: typing.Union[Unset, Schema] - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset def __init__( self, response: urllib3.HTTPResponse, - body: typing.Union[Unset, typing.Type[Schema]], - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset, + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset ): \\"\\"\\" pycharm needs this to prevent 'Unexpected argument' warnings @@ -9063,23 +18175,6 @@ class ApiResponseWithoutDeserialization(ApiResponse): headers: typing.Union[Unset, typing.List[HeaderParameter]] = unset -class JSONDetector: - \\"\\"\\" - Works for: - application/json - application/json; charset=UTF-8 - application/json-patch+json - application/geo+json - \\"\\"\\" - __json_content_type_pattern = re.compile(\\"application/[^+]*[+]?(json);?.*\\") - - @classmethod - def _content_type_is_json(cls, content_type: str) -> bool: - if cls.__json_content_type_pattern.match(content_type): - return True - return False - - class OpenApiResponse(JSONDetector): __filename_content_disposition_pattern = re.compile('filename=\\"(.+?)\\"') @@ -9100,6 +18195,19 @@ class OpenApiResponse(JSONDetector): # python must be >= 3.9 so we can pass in bytes into json.loads return json.loads(response.data) + @staticmethod + def __file_name_from_response_url(response_url: typing.Optional[str]) -> typing.Optional[str]: + if response_url is None: + return None + url_path = urlparse(response_url).path + if url_path: + path_basename = os.path.basename(url_path) + if path_basename: + _filename, ext = os.path.splitext(path_basename) + if ext: + return path_basename + return None + @classmethod def __file_name_from_content_disposition(cls, content_disposition: typing.Optional[str]) -> typing.Optional[str]: if content_disposition is None: @@ -9119,13 +18227,16 @@ class OpenApiResponse(JSONDetector): a file will be written and returned \\"\\"\\" if response.supports_chunked_reads(): - file_name = self.__file_name_from_content_disposition(response.headers.get('content-disposition')) + file_name = ( + self.__file_name_from_content_disposition(response.headers.get('content-disposition')) + or self.__file_name_from_response_url(response.geturl()) + ) if file_name is None: _fd, path = tempfile.mkstemp() else: path = os.path.join(tempfile.gettempdir(), file_name) - # TODO get file_name from the filename at the end of the url if it exists + with open(path, 'wb') as new_file: chunk_size = 1024 while True: @@ -9167,8 +18278,8 @@ class OpenApiResponse(JSONDetector): if self.content is not None: if content_type not in self.content: raise ApiValueError( - f'Invalid content_type={content_type} returned for response with ' - 'status_code={str(response.status)}' + f\\"Invalid content_type returned. Content_type='{content_type}' was returned \\" + f\\"when only {str(set(self.content))} are defined for status_code={str(response.status)}\\" ) body_schema = self.content[content_type].schema if body_schema is None: @@ -9238,7 +18349,7 @@ class ApiClient: self.pool_threads = pool_threads self.rest_client = rest.RESTClientObject(configuration) - self.default_headers = {} + self.default_headers = HTTPHeaderDict() if header_name is not None: self.default_headers[header_name] = header_value self.cookie = cookie @@ -9295,15 +18406,18 @@ class ApiClient: ) -> urllib3.HTTPResponse: # header parameters - headers = headers or {} - headers.update(self.default_headers) + used_headers = HTTPHeaderDict(self.default_headers) if self.cookie: headers['Cookie'] = self.cookie # auth setting - self.update_params_for_auth(headers, + self.update_params_for_auth(used_headers, auth_settings, resource_path, method, body) + # must happen after cookie setting and auth setting in case user is overriding those + if headers: + used_headers.update(headers) + # request url if host is None: url = self.configuration.host + resource_path @@ -9315,7 +18429,7 @@ class ApiClient: response = self.request( method, url, - headers=headers, + headers=used_headers, fields=fields, body=body, stream=stream, @@ -9508,7 +18622,7 @@ class Api: self.api_client = api_client @staticmethod - def _verify_typed_dict_inputs_oapg(cls: typing.Type[typing.TypedDict], data: typing.Dict[str, typing.Any]): + def _verify_typed_dict_inputs_oapg(cls: typing.Type[typing_extensions.TypedDict], data: typing.Dict[str, typing.Any]): \\"\\"\\" Ensures that: - required keys are present @@ -9580,9 +18694,9 @@ class Api: return host -class SerializedRequestBody(typing.TypedDict, total=False): +class SerializedRequestBody(typing_extensions.TypedDict, total=False): body: typing.Union[str, bytes] - fields: typing.Tuple[typing.Union[RequestField, tuple[str, str]], ...] + fields: typing.Tuple[typing.Union[RequestField, typing.Tuple[str, str]], ...] class RequestBody(StyleFormSerializer, JSONDetector): @@ -9626,24 +18740,24 @@ class RequestBody(StyleFormSerializer, JSONDetector): def __multipart_json_item(self, key: str, value: Schema) -> RequestField: json_value = self.__json_encoder.default(value) - return RequestField(name=key, data=json.dumps(json_value), headers={'Content-Type': 'application/json'}) + request_field = RequestField(name=key, data=json.dumps(json_value)) + request_field.make_multipart(content_type='application/json') + return request_field def __multipart_form_item(self, key: str, value: Schema) -> RequestField: if isinstance(value, str): - return RequestField(name=key, data=str(value), headers={'Content-Type': 'text/plain'}) + request_field = RequestField(name=key, data=str(value)) + request_field.make_multipart(content_type='text/plain') elif isinstance(value, bytes): - return RequestField(name=key, data=value, headers={'Content-Type': 'application/octet-stream'}) + request_field = RequestField(name=key, data=value) + request_field.make_multipart(content_type='application/octet-stream') elif isinstance(value, FileIO): - request_field = RequestField( - name=key, - data=value.read(), - filename=os.path.basename(value.name), - headers={'Content-Type': 'application/octet-stream'} - ) + # TODO use content.encoding to limit allowed content types if they are present + request_field = RequestField.from_tuples(key, (os.path.basename(value.name), value.read())) value.close() - return request_field else: - return self.__multipart_json_item(key=key, value=value) + request_field = self.__multipart_json_item(key=key, value=value) + return request_field def __serialize_multipart_form_data( self, in_data: Schema @@ -9699,7 +18813,7 @@ class RequestBody(StyleFormSerializer, JSONDetector): raise ValueError( f'Unable to serialize {in_data} to application/x-www-form-urlencoded because it is not a dict of data') cast_in_data = self.__json_encoder.default(in_data) - value = self._serialize_form(cast_in_data, name='', explode=True, percent_encode=False) + value = self._serialize_form(cast_in_data, name='', explode=True, percent_encode=True) return dict(body=value) def serialize( @@ -9733,12 +18847,11 @@ class RequestBody(StyleFormSerializer, JSONDetector): return self.__serialize_application_x_www_form_data(cast_in_data) elif content_type == 'application/octet-stream': return self.__serialize_application_octet_stream(cast_in_data) - raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type)) -", + raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type))", "test/apis/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames # if you need the ability to import all endpoints then import them from # tags, paths, or path_to_api, or tag_to_api", - "test/apis/path_to_api.py": "import typing + "test/apis/path_to_api.py": "import typing_extensions from test.paths import PathValues from test.apis.paths.path_path_param import PathPathParam @@ -9747,7 +18860,7 @@ from test.apis.paths.empty_response import EmptyResponse from test.apis.paths.any_request_response import AnyRequestResponse from test.apis.paths.different_media_type import DifferentMediaType -PathToApi = typing.TypedDict( +PathToApi = typing_extensions.TypedDict( 'PathToApi', { PathValues.PATH_PATH_PARAM: PathPathParam, @@ -9812,12 +18925,12 @@ class WithoutOperationId( ): pass ", - "test/apis/tag_to_api.py": "import typing + "test/apis/tag_to_api.py": "import typing_extensions from test.apis.tags import TagValues from test.apis.tags.default_api import DefaultApi -TagToApi = typing.TypedDict( +TagToApi = typing_extensions.TypedDict( 'TagToApi', { TagValues.DEFAULT: DefaultApi, @@ -10493,14 +19606,16 @@ class Configuration(object): _default = None - def __init__(self, host=None, - api_key=None, api_key_prefix=None, - username=None, password=None, - discard_unknown_keys=False, - disabled_client_side_validations=\\"\\", - server_index=None, server_variables=None, - server_operation_index=None, server_operation_variables=None, - ): + def __init__( + self, + host=None, + discard_unknown_keys=False, + disabled_client_side_validations=\\"\\", + server_index=None, + server_variables=None, + server_operation_index=None, + server_operation_variables=None, + ): \\"\\"\\"Constructor \\"\\"\\" self._base_path = \\"http://localhost\\" if host is None else host @@ -10518,26 +19633,6 @@ class Configuration(object): \\"\\"\\"Temp file folder for downloading files \\"\\"\\" # Authentication Settings - self.api_key = {} - if api_key: - self.api_key = api_key - \\"\\"\\"dict to store API key(s) - \\"\\"\\" - self.api_key_prefix = {} - if api_key_prefix: - self.api_key_prefix = api_key_prefix - \\"\\"\\"dict to store API prefix (e.g. Bearer) - \\"\\"\\" - self.refresh_api_key_hook = None - \\"\\"\\"function hook to refresh API key if expired - \\"\\"\\" - self.username = username - \\"\\"\\"Username for HTTP basic authentication - \\"\\"\\" - self.password = password - \\"\\"\\"Password for HTTP basic authentication - \\"\\"\\" - self.discard_unknown_keys = discard_unknown_keys self.disabled_client_side_validations = disabled_client_side_validations self.logger = {} \\"\\"\\"Logging Settings @@ -10871,6 +19966,10 @@ class Configuration(object): The version of the OpenAPI document: 1.0.0 Generated by: https://openapi-generator.tech \\"\\"\\" +import dataclasses +import typing + +from urllib3._collections import HTTPHeaderDict class OpenApiException(Exception): @@ -10960,19 +20059,26 @@ class ApiKeyError(OpenApiException, KeyError): super(ApiKeyError, self).__init__(full_msg) -class ApiException(OpenApiException): +T = typing.TypeVar(\\"T\\") - def __init__(self, status=None, reason=None, api_response: 'test.api_client.ApiResponse' = None): - if api_response: - self.status = api_response.response.status - self.reason = api_response.response.reason - self.body = api_response.response.data - self.headers = api_response.response.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + +@dataclasses.dataclass +class ApiException(OpenApiException, typing.Generic[T]): + status: int + reason: str + api_response: typing.Optional[T] = None + + @property + def body(self) -> typing.Union[str, bytes, None]: + if not self.api_response: + return None + return self.api_response.response.data + + @property + def headers(self) -> typing.Optional[HTTPHeaderDict]: + if not self.api_response: + return None + return self.api_response.response.getheaders() def __str__(self): \\"\\"\\"Custom error messages for exception\\"\\"\\" @@ -11021,6 +20127,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -11042,6 +20149,7 @@ class ApiError( required = { \\"errorMessage\\", } + class properties: errorMessage = schemas.StrSchema __annotations__ = { @@ -11051,36 +20159,36 @@ class ApiError( errorMessage: MetaOapg.properties.errorMessage @typing.overload - def __getitem__(self, name: typing.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... + def __getitem__(self, name: typing_extensions.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"errorMessage\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"errorMessage\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"errorMessage\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"errorMessage\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], + *_args: typing.Union[dict, frozendict.frozendict, ], errorMessage: typing.Union[MetaOapg.properties.errorMessage, str, ], _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'ApiError': return super().__new__( cls, - *args, + *_args, errorMessage=errorMessage, _configuration=_configuration, **kwargs, @@ -11103,6 +20211,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -11124,6 +20233,7 @@ class ApiError( required = { \\"errorMessage\\", } + class properties: errorMessage = schemas.StrSchema __annotations__ = { @@ -11133,36 +20243,36 @@ class ApiError( errorMessage: MetaOapg.properties.errorMessage @typing.overload - def __getitem__(self, name: typing.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... + def __getitem__(self, name: typing_extensions.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"errorMessage\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"errorMessage\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"errorMessage\\"]) -> MetaOapg.properties.errorMessage: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"errorMessage\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"errorMessage\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], + *_args: typing.Union[dict, frozendict.frozendict, ], errorMessage: typing.Union[MetaOapg.properties.errorMessage, str, ], _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'ApiError': return super().__new__( cls, - *args, + *_args, errorMessage=errorMessage, _configuration=_configuration, **kwargs, @@ -11185,6 +20295,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -11203,6 +20314,7 @@ class TestRequest( class MetaOapg: + class properties: myInput = schemas.NumberSchema __annotations__ = { @@ -11210,36 +20322,36 @@ class TestRequest( } @typing.overload - def __getitem__(self, name: typing.Literal[\\"myInput\\"]) -> MetaOapg.properties.myInput: ... + def __getitem__(self, name: typing_extensions.Literal[\\"myInput\\"]) -> MetaOapg.properties.myInput: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"myInput\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"myInput\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"myInput\\"]) -> typing.Union[MetaOapg.properties.myInput, schemas.Unset]: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"myInput\\"]) -> typing.Union[MetaOapg.properties.myInput, schemas.Unset]: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"myInput\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"myInput\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], + *_args: typing.Union[dict, frozendict.frozendict, ], myInput: typing.Union[MetaOapg.properties.myInput, decimal.Decimal, int, float, schemas.Unset] = schemas.unset, _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'TestRequest': return super().__new__( cls, - *args, + *_args, myInput=myInput, _configuration=_configuration, **kwargs, @@ -11262,6 +20374,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -11280,6 +20393,7 @@ class TestRequest( class MetaOapg: + class properties: myInput = schemas.NumberSchema __annotations__ = { @@ -11287,36 +20401,36 @@ class TestRequest( } @typing.overload - def __getitem__(self, name: typing.Literal[\\"myInput\\"]) -> MetaOapg.properties.myInput: ... + def __getitem__(self, name: typing_extensions.Literal[\\"myInput\\"]) -> MetaOapg.properties.myInput: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"myInput\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"myInput\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"myInput\\"]) -> typing.Union[MetaOapg.properties.myInput, schemas.Unset]: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"myInput\\"]) -> typing.Union[MetaOapg.properties.myInput, schemas.Unset]: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"myInput\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"myInput\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], + *_args: typing.Union[dict, frozendict.frozendict, ], myInput: typing.Union[MetaOapg.properties.myInput, decimal.Decimal, int, float, schemas.Unset] = schemas.unset, _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'TestRequest': return super().__new__( cls, - *args, + *_args, myInput=myInput, _configuration=_configuration, **kwargs, @@ -11339,6 +20453,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -11360,6 +20475,7 @@ class TestResponse( required = { \\"messages\\", } + class properties: @@ -11380,6 +20496,7 @@ class TestResponse( required = { \\"id\\", } + class properties: message = schemas.StrSchema id = schemas.IntSchema @@ -11391,43 +20508,43 @@ class TestResponse( id: MetaOapg.properties.id @typing.overload - def __getitem__(self, name: typing.Literal[\\"message\\"]) -> MetaOapg.properties.message: ... + def __getitem__(self, name: typing_extensions.Literal[\\"message\\"]) -> MetaOapg.properties.message: ... @typing.overload - def __getitem__(self, name: typing.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... + def __getitem__(self, name: typing_extensions.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"message\\", \\"id\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"message\\", \\"id\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"message\\"]) -> typing.Union[MetaOapg.properties.message, schemas.Unset]: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"message\\"]) -> typing.Union[MetaOapg.properties.message, schemas.Unset]: ... @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"message\\", \\"id\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"message\\", \\"id\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], - id: typing.Union[MetaOapg.properties.id, int, ], + *_args: typing.Union[dict, frozendict.frozendict, ], + id: typing.Union[MetaOapg.properties.id, decimal.Decimal, int, ], message: typing.Union[MetaOapg.properties.message, str, schemas.Unset] = schemas.unset, _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'items': return super().__new__( cls, - *args, + *_args, id=id, message=message, _configuration=_configuration, @@ -11436,12 +20553,12 @@ class TestResponse( def __new__( cls, - arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]]], + _arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]]], _configuration: typing.Optional[schemas.Configuration] = None, ) -> 'messages': return super().__new__( cls, - arg, + _arg, _configuration=_configuration, ) @@ -11454,36 +20571,36 @@ class TestResponse( messages: MetaOapg.properties.messages @typing.overload - def __getitem__(self, name: typing.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... + def __getitem__(self, name: typing_extensions.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"messages\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"messages\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"messages\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"messages\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], - messages: typing.Union[MetaOapg.properties.messages, tuple, ], + *_args: typing.Union[dict, frozendict.frozendict, ], + messages: typing.Union[MetaOapg.properties.messages, list, tuple, ], _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'TestResponse': return super().__new__( cls, - *args, + *_args, messages=messages, _configuration=_configuration, **kwargs, @@ -11506,6 +20623,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -11527,6 +20645,7 @@ class TestResponse( required = { \\"messages\\", } + class properties: @@ -11547,6 +20666,7 @@ class TestResponse( required = { \\"id\\", } + class properties: message = schemas.StrSchema id = schemas.IntSchema @@ -11558,43 +20678,43 @@ class TestResponse( id: MetaOapg.properties.id @typing.overload - def __getitem__(self, name: typing.Literal[\\"message\\"]) -> MetaOapg.properties.message: ... + def __getitem__(self, name: typing_extensions.Literal[\\"message\\"]) -> MetaOapg.properties.message: ... @typing.overload - def __getitem__(self, name: typing.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... + def __getitem__(self, name: typing_extensions.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"message\\", \\"id\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"message\\", \\"id\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"message\\"]) -> typing.Union[MetaOapg.properties.message, schemas.Unset]: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"message\\"]) -> typing.Union[MetaOapg.properties.message, schemas.Unset]: ... @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"id\\"]) -> MetaOapg.properties.id: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"message\\", \\"id\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"message\\", \\"id\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], - id: typing.Union[MetaOapg.properties.id, int, ], + *_args: typing.Union[dict, frozendict.frozendict, ], + id: typing.Union[MetaOapg.properties.id, decimal.Decimal, int, ], message: typing.Union[MetaOapg.properties.message, str, schemas.Unset] = schemas.unset, _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'items': return super().__new__( cls, - *args, + *_args, id=id, message=message, _configuration=_configuration, @@ -11603,12 +20723,12 @@ class TestResponse( def __new__( cls, - arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]]], + _arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, ]]], _configuration: typing.Optional[schemas.Configuration] = None, ) -> 'messages': return super().__new__( cls, - arg, + _arg, _configuration=_configuration, ) @@ -11621,36 +20741,36 @@ class TestResponse( messages: MetaOapg.properties.messages @typing.overload - def __getitem__(self, name: typing.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... + def __getitem__(self, name: typing_extensions.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... @typing.overload def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... - def __getitem__(self, name: typing.Union[typing.Literal[\\"messages\\", ], str]): + def __getitem__(self, name: typing.Union[typing_extensions.Literal[\\"messages\\", ], str]): # dict_instance[name] accessor return super().__getitem__(name) @typing.overload - def get_item_oapg(self, name: typing.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... + def get_item_oapg(self, name: typing_extensions.Literal[\\"messages\\"]) -> MetaOapg.properties.messages: ... @typing.overload def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ... - def get_item_oapg(self, name: typing.Union[typing.Literal[\\"messages\\", ], str]): + def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[\\"messages\\", ], str]): return super().get_item_oapg(name) def __new__( cls, - *args: typing.Union[dict, frozendict.frozendict, ], - messages: typing.Union[MetaOapg.properties.messages, tuple, ], + *_args: typing.Union[dict, frozendict.frozendict, ], + messages: typing.Union[MetaOapg.properties.messages, list, tuple, ], _configuration: typing.Optional[schemas.Configuration] = None, **kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes], ) -> 'TestResponse': return super().__new__( cls, - *args, + *_args, messages=messages, _configuration=_configuration, **kwargs, @@ -11664,7 +20784,7 @@ class TestResponse( # if you have many models here with many references from one model to another this may # raise a RecursionError # to avoid this, import only the models that you directly need like: -# from from test.model.pet import Pet +# from test.model.pet import Pet # or import this package, but before doing it, use: # import sys # sys.setrecursionlimit(n) @@ -11703,6 +20823,7 @@ path = PathValues.ANYREQUESTRESPONSE", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -11713,6 +20834,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -11759,19 +20881,67 @@ _all_accept_content_types = ( class BaseApi(api_client.Api): + @typing.overload + def _any_request_response_oapg( + self, + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _any_request_response_oapg( - self: api_client.Api, - body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, schemas.Unset] = schemas.unset, - content_type: str = 'application/json', + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + ]: ... + + + @typing.overload + def _any_request_response_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _any_request_response_oapg( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _any_request_response_oapg( + self, + content_type: str = 'application/json', + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -11814,7 +20984,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -11822,18 +20996,67 @@ class BaseApi(api_client.Api): class AnyRequestResponse(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def any_request_response( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, schemas.Unset] = schemas.unset, - content_type: str = 'application/json', + self, + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def any_request_response( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def any_request_response( + self, + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def any_request_response( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def any_request_response( + self, + content_type: str = 'application/json', + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._any_request_response_oapg( body=body, content_type=content_type, @@ -11847,18 +21070,67 @@ class AnyRequestResponse(BaseApi): class ApiForput(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def put( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, schemas.Unset] = schemas.unset, - content_type: str = 'application/json', + self, + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def put( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def put( + self, + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def put( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def put( + self, + content_type: str = 'application/json', + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._any_request_response_oapg( body=body, content_type=content_type, @@ -11879,6 +21151,7 @@ class ApiForput(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -11889,6 +21162,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -11897,26 +21171,100 @@ from test import schemas # noqa: F401 # body param SchemaForRequestBodyApplicationJson = schemas.AnyTypeSchema + + +request_body_body = api_client.RequestBody( + content={ + 'application/json': api_client.MediaType( + schema=SchemaForRequestBodyApplicationJson), + }, +) SchemaFor200ResponseBodyApplicationJson = schemas.AnyTypeSchema + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[ + SchemaFor200ResponseBodyApplicationJson, + ] + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, + content={ + 'application/json': api_client.MediaType( + schema=SchemaFor200ResponseBodyApplicationJson), + }, +) _all_accept_content_types = ( 'application/json', ) class BaseApi(api_client.Api): + @typing.overload + def _any_request_response_oapg( + self, + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _any_request_response_oapg( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def _any_request_response_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _any_request_response_oapg( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... def _any_request_response_oapg( - self: api_client.Api, - body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, schemas.Unset] = schemas.unset, + self, content_type: str = 'application/json', + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, skip_deserialization: bool = False, - ) -> typing.Union[ - ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -11959,7 +21307,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -11967,18 +21319,67 @@ class BaseApi(api_client.Api): class AnyRequestResponse(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def any_request_response( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, schemas.Unset] = schemas.unset, - content_type: str = 'application/json', + self, + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def any_request_response( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def any_request_response( + self, + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def any_request_response( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def any_request_response( + self, + content_type: str = 'application/json', + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._any_request_response_oapg( body=body, content_type=content_type, @@ -11992,18 +21393,67 @@ class AnyRequestResponse(BaseApi): class ApiForput(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def put( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, schemas.Unset] = schemas.unset, - content_type: str = 'application/json', + self, + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def put( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def put( + self, + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def put( + self, + content_type: str = ..., + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def put( + self, + content_type: str = 'application/json', + body: typing.Union[SchemaForRequestBodyApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, schemas.Unset] = schemas.unset, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._any_request_response_oapg( body=body, content_type=content_type, @@ -12031,6 +21481,7 @@ path = PathValues.DIFFERENTMEDIATYPE", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -12041,6 +21492,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -12088,19 +21540,67 @@ _all_accept_content_types = ( class BaseApi(api_client.Api): + @typing.overload + def _media_types_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: typing_extensions.Literal[\\"application/pdf\\"] = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _media_types_oapg( - self: api_client.Api, - body: typing.Union[SchemaForRequestBodyApplicationPdf, bytes, io.FileIO, io.BufferedReader, ], - content_type: str = 'application/pdf', + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def _media_types_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _media_types_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _media_types_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = 'application/pdf', + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -12145,7 +21645,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -12153,18 +21657,67 @@ class BaseApi(api_client.Api): class MediaTypes(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload + def media_types( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: typing_extensions.Literal[\\"application/pdf\\"] = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload def media_types( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationPdf, bytes, io.FileIO, io.BufferedReader, ], - content_type: str = 'application/pdf', + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def media_types( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def media_types( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def media_types( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = 'application/pdf', + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._media_types_oapg( body=body, content_type=content_type, @@ -12178,18 +21731,67 @@ class MediaTypes(BaseApi): class ApiForpost(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def post( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationPdf, bytes, io.FileIO, io.BufferedReader, ], - content_type: str = 'application/pdf', + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: typing_extensions.Literal[\\"application/pdf\\"] = ..., accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = 'application/pdf', + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._media_types_oapg( body=body, content_type=content_type, @@ -12210,6 +21812,7 @@ class ApiForpost(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -12220,6 +21823,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -12228,26 +21832,101 @@ from test import schemas # noqa: F401 # body param SchemaForRequestBodyApplicationPdf = schemas.BinarySchema + + +request_body_body = api_client.RequestBody( + content={ + 'application/pdf': api_client.MediaType( + schema=SchemaForRequestBodyApplicationPdf), + }, + required=True, +) SchemaFor200ResponseBodyApplicationXMpegurl = schemas.StrSchema + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[ + SchemaFor200ResponseBodyApplicationXMpegurl, + ] + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, + content={ + 'application/x-mpegurl': api_client.MediaType( + schema=SchemaFor200ResponseBodyApplicationXMpegurl), + }, +) _all_accept_content_types = ( 'application/x-mpegurl', ) -class BaseApi(api_client.Api): +class BaseApi(api_client.Api): + @typing.overload + def _media_types_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: typing_extensions.Literal[\\"application/pdf\\"] = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _media_types_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def _media_types_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _media_types_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... def _media_types_oapg( - self: api_client.Api, - body: typing.Union[SchemaForRequestBodyApplicationPdf, bytes, io.FileIO, io.BufferedReader, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], content_type: str = 'application/pdf', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, skip_deserialization: bool = False, - ) -> typing.Union[ - ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -12292,7 +21971,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -12300,18 +21983,67 @@ class BaseApi(api_client.Api): class MediaTypes(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def media_types( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationPdf, bytes, io.FileIO, io.BufferedReader, ], - content_type: str = 'application/pdf', + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: typing_extensions.Literal[\\"application/pdf\\"] = ..., accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def media_types( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def media_types( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def media_types( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def media_types( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = 'application/pdf', + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._media_types_oapg( body=body, content_type=content_type, @@ -12325,18 +22057,67 @@ class MediaTypes(BaseApi): class ApiForpost(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def post( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationPdf, bytes, io.FileIO, io.BufferedReader, ], - content_type: str = 'application/pdf', + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: typing_extensions.Literal[\\"application/pdf\\"] = ..., accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = ..., + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationPdf,bytes, io.FileIO, io.BufferedReader, ], + content_type: str = 'application/pdf', + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._media_types_oapg( body=body, content_type=content_type, @@ -12364,6 +22145,7 @@ path = PathValues.EMPTYRESPONSE", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -12373,6 +22155,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -12399,16 +22182,41 @@ _status_code_to_response = { class BaseApi(api_client.Api): + @typing.overload + def _empty_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor204, + ]: ... + + @typing.overload + def _empty_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + @typing.overload def _empty_oapg( - self: api_client.Api, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor204, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _empty_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -12434,7 +22242,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -12442,15 +22254,41 @@ class BaseApi(api_client.Api): class Empty(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def empty( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor204, + ]: ... + + @typing.overload + def empty( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def empty( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor204, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def empty( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._empty_oapg( stream=stream, timeout=timeout, @@ -12461,15 +22299,41 @@ class Empty(BaseApi): class ApiForput(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload + def put( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor204, + ]: ... + + @typing.overload + def put( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload def put( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor204, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def put( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._empty_oapg( stream=stream, timeout=timeout, @@ -12487,6 +22351,7 @@ class ApiForput(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -12496,6 +22361,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -12504,17 +22370,54 @@ from test import schemas # noqa: F401 +@dataclass +class ApiResponseFor204(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_204 = api_client.OpenApiResponse( + response_cls=ApiResponseFor204, +) + + class BaseApi(api_client.Api): + @typing.overload + def _empty_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor204, + ]: ... + @typing.overload def _empty_oapg( - self: api_client.Api, + self, + skip_deserialization: typing_extensions.Literal[True], stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _empty_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor204, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _empty_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -12540,7 +22443,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -12548,15 +22455,41 @@ class BaseApi(api_client.Api): class Empty(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def empty( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor204, + ]: ... + + @typing.overload + def empty( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def empty( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor204, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def empty( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._empty_oapg( stream=stream, timeout=timeout, @@ -12567,15 +22500,41 @@ class Empty(BaseApi): class ApiForput(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def put( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor204, + ]: ... + + @typing.overload + def put( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def put( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor204, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def put( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._empty_oapg( stream=stream, timeout=timeout, @@ -12600,6 +22559,7 @@ path = PathValues.PATH_PATH_PARAM", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -12610,6 +22570,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -12622,7 +22583,7 @@ from test.model.test_request import TestRequest from . import path -# query params +# Query params Param1Schema = schemas.StrSchema @@ -12636,12 +22597,12 @@ class Param2Schema( def __new__( cls, - arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, str, ]], typing.List[typing.Union[MetaOapg.items, str, ]]], + _arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, str, ]], typing.List[typing.Union[MetaOapg.items, str, ]]], _configuration: typing.Optional[schemas.Configuration] = None, ) -> 'Param2Schema': return super().__new__( cls, - arg, + _arg, _configuration=_configuration, ) @@ -12649,15 +22610,15 @@ class Param2Schema( return super().__getitem__(i) Param3Schema = schemas.NumberSchema Param4Schema = schemas.StrSchema -RequestRequiredQueryParams = typing.TypedDict( +RequestRequiredQueryParams = typing_extensions.TypedDict( 'RequestRequiredQueryParams', { 'param1': typing.Union[Param1Schema, str, ], - 'param2': typing.Union[Param2Schema, tuple, ], + 'param2': typing.Union[Param2Schema, list, tuple, ], 'param3': typing.Union[Param3Schema, decimal.Decimal, int, float, ], } ) -RequestOptionalQueryParams = typing.TypedDict( +RequestOptionalQueryParams = typing_extensions.TypedDict( 'RequestOptionalQueryParams', { 'param4': typing.Union[Param4Schema, str, ], @@ -12697,15 +22658,15 @@ request_query_param4 = api_client.QueryParameter( schema=Param4Schema, explode=True, ) -# path params +# Path params PathParamSchema = schemas.StrSchema -RequestRequiredPathParams = typing.TypedDict( +RequestRequiredPathParams = typing_extensions.TypedDict( 'RequestRequiredPathParams', { 'pathParam': typing.Union[PathParamSchema, str, ], } ) -RequestOptionalPathParams = typing.TypedDict( +RequestOptionalPathParams = typing_extensions.TypedDict( 'RequestOptionalPathParams', { }, @@ -12781,22 +22742,78 @@ _all_accept_content_types = ( ) -class BaseApi(api_client.Api): +class BaseApi(api_client.Api): + @typing.overload + def _operation_one_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _operation_one_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload def _operation_one_oapg( - self: api_client.Api, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., query_params: RequestQueryParams = frozendict.frozendict(), path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _operation_one_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _operation_one_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -12872,7 +22889,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -12880,20 +22901,77 @@ class BaseApi(api_client.Api): class OperationOne(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def operation_one( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., query_params: RequestQueryParams = frozendict.frozendict(), path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def operation_one( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def operation_one( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def operation_one( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def operation_one( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._operation_one_oapg( body=body, query_params=query_params, @@ -12909,20 +22987,77 @@ class OperationOne(BaseApi): class ApiForpost(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def post( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., query_params: RequestQueryParams = frozendict.frozendict(), path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._operation_one_oapg( body=body, query_params=query_params, @@ -12945,6 +23080,7 @@ class ApiForpost(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -12955,6 +23091,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -12965,7 +23102,7 @@ from test.model.test_response import TestResponse from test.model.api_error import ApiError from test.model.test_request import TestRequest -# query params +# Query params Param1Schema = schemas.StrSchema @@ -12977,48 +23114,221 @@ class Param2Schema( class MetaOapg: items = schemas.StrSchema - def __new__( - cls, - arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, str, ]], typing.List[typing.Union[MetaOapg.items, str, ]]], - _configuration: typing.Optional[schemas.Configuration] = None, - ) -> 'Param2Schema': - return super().__new__( - cls, - arg, - _configuration=_configuration, - ) + def __new__( + cls, + _arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, str, ]], typing.List[typing.Union[MetaOapg.items, str, ]]], + _configuration: typing.Optional[schemas.Configuration] = None, + ) -> 'Param2Schema': + return super().__new__( + cls, + _arg, + _configuration=_configuration, + ) + + def __getitem__(self, i: int) -> MetaOapg.items: + return super().__getitem__(i) +Param3Schema = schemas.NumberSchema +Param4Schema = schemas.StrSchema +RequestRequiredQueryParams = typing_extensions.TypedDict( + 'RequestRequiredQueryParams', + { + 'param1': typing.Union[Param1Schema, str, ], + 'param2': typing.Union[Param2Schema, list, tuple, ], + 'param3': typing.Union[Param3Schema, decimal.Decimal, int, float, ], + } +) +RequestOptionalQueryParams = typing_extensions.TypedDict( + 'RequestOptionalQueryParams', + { + 'param4': typing.Union[Param4Schema, str, ], + }, + total=False +) + + +class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams): + pass + + +request_query_param1 = api_client.QueryParameter( + name=\\"param1\\", + style=api_client.ParameterStyle.FORM, + schema=Param1Schema, + required=True, + explode=True, +) +request_query_param2 = api_client.QueryParameter( + name=\\"param2\\", + style=api_client.ParameterStyle.FORM, + schema=Param2Schema, + required=True, + explode=True, +) +request_query_param3 = api_client.QueryParameter( + name=\\"param3\\", + style=api_client.ParameterStyle.FORM, + schema=Param3Schema, + required=True, + explode=True, +) +request_query_param4 = api_client.QueryParameter( + name=\\"param4\\", + style=api_client.ParameterStyle.FORM, + schema=Param4Schema, + explode=True, +) +# Path params +PathParamSchema = schemas.StrSchema +RequestRequiredPathParams = typing_extensions.TypedDict( + 'RequestRequiredPathParams', + { + 'pathParam': typing.Union[PathParamSchema, str, ], + } +) +RequestOptionalPathParams = typing_extensions.TypedDict( + 'RequestOptionalPathParams', + { + }, + total=False +) + + +class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams): + pass + + +request_path_path_param = api_client.PathParameter( + name=\\"pathParam\\", + style=api_client.ParameterStyle.SIMPLE, + schema=PathParamSchema, + required=True, +) +# body param +SchemaForRequestBodyApplicationJson = TestRequest + + +request_body_test_request = api_client.RequestBody( + content={ + 'application/json': api_client.MediaType( + schema=SchemaForRequestBodyApplicationJson), + }, + required=True, +) +SchemaFor200ResponseBodyApplicationJson = TestResponse + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[ + SchemaFor200ResponseBodyApplicationJson, + ] + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, + content={ + 'application/json': api_client.MediaType( + schema=SchemaFor200ResponseBodyApplicationJson), + }, +) +SchemaFor400ResponseBodyApplicationJson = ApiError + + +@dataclass +class ApiResponseFor400(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[ + SchemaFor400ResponseBodyApplicationJson, + ] + headers: schemas.Unset = schemas.unset + - def __getitem__(self, i: int) -> MetaOapg.items: - return super().__getitem__(i) -Param3Schema = schemas.NumberSchema -Param4Schema = schemas.StrSchema -# path params -PathParamSchema = schemas.StrSchema -# body param -SchemaForRequestBodyApplicationJson = TestRequest -SchemaFor200ResponseBodyApplicationJson = TestResponse -SchemaFor400ResponseBodyApplicationJson = ApiError +_response_for_400 = api_client.OpenApiResponse( + response_cls=ApiResponseFor400, + content={ + 'application/json': api_client.MediaType( + schema=SchemaFor400ResponseBodyApplicationJson), + }, +) _all_accept_content_types = ( 'application/json', ) class BaseApi(api_client.Api): + @typing.overload + def _operation_one_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _operation_one_oapg( - self: api_client.Api, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., query_params: RequestQueryParams = frozendict.frozendict(), path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def _operation_one_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _operation_one_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _operation_one_oapg( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -13094,7 +23404,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -13102,20 +23416,77 @@ class BaseApi(api_client.Api): class OperationOne(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def operation_one( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., query_params: RequestQueryParams = frozendict.frozendict(), path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def operation_one( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def operation_one( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def operation_one( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def operation_one( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._operation_one_oapg( body=body, query_params=query_params, @@ -13131,20 +23502,77 @@ class OperationOne(BaseApi): class ApiForpost(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def post( - self: BaseApi, - body: typing.Union[SchemaForRequestBodyApplicationJson, ], + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: typing_extensions.Literal[\\"application/json\\"] = ..., query_params: RequestQueryParams = frozendict.frozendict(), path_params: RequestPathParams = frozendict.frozendict(), - content_type: str = 'application/json', accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + ]: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + skip_deserialization: typing_extensions.Literal[True], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = ..., + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def post( + self, + body: typing.Union[SchemaForRequestBodyApplicationJson,], + content_type: str = 'application/json', + query_params: RequestQueryParams = frozendict.frozendict(), + path_params: RequestPathParams = frozendict.frozendict(), + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._operation_one_oapg( body=body, query_params=query_params, @@ -13174,6 +23602,7 @@ path = PathValues.WITHOUTOPERATIONID", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -13184,6 +23613,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -13222,17 +23652,45 @@ _all_accept_content_types = ( class BaseApi(api_client.Api): + @typing.overload + def _without_operation_id_delete_oapg( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _without_operation_id_delete_oapg( - self: api_client.Api, + self, + skip_deserialization: typing_extensions.Literal[True], accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _without_operation_id_delete_oapg( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _without_operation_id_delete_oapg( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -13264,7 +23722,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -13272,37 +23734,95 @@ class BaseApi(api_client.Api): class WithoutOperationIdDelete(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names - def without_operation_id_delete( - self: BaseApi, + @typing.overload + def without_operation_id_delete( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def without_operation_id_delete( + self, + skip_deserialization: typing_extensions.Literal[True], + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def without_operation_id_delete( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def without_operation_id_delete( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): + return self._without_operation_id_delete_oapg( + accept_content_types=accept_content_types, + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiFordelete(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + @typing.overload + def delete( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def delete( + self, + skip_deserialization: typing_extensions.Literal[True], + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def delete( + self, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: - return self._without_operation_id_delete_oapg( - accept_content_types=accept_content_types, - stream=stream, - timeout=timeout, - skip_deserialization=skip_deserialization - ) - - -class ApiFordelete(BaseApi): - # this class is used by api classes that refer to endpoints by path and http method names + api_client.ApiResponseWithoutDeserialization, + ]: ... def delete( - self: BaseApi, + self, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, skip_deserialization: bool = False, - ) -> typing.Union[ - ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + ): return self._without_operation_id_delete_oapg( accept_content_types=accept_content_types, stream=stream, @@ -13321,6 +23841,7 @@ class ApiFordelete(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict @@ -13331,6 +23852,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -13340,23 +23862,69 @@ from test import schemas # noqa: F401 from test.model.test_response import TestResponse SchemaFor200ResponseBodyApplicationJson = TestResponse + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[ + SchemaFor200ResponseBodyApplicationJson, + ] + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, + content={ + 'application/json': api_client.MediaType( + schema=SchemaFor200ResponseBodyApplicationJson), + }, +) _all_accept_content_types = ( 'application/json', ) class BaseApi(api_client.Api): + @typing.overload + def _without_operation_id_delete_oapg( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _without_operation_id_delete_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + @typing.overload def _without_operation_id_delete_oapg( - self: api_client.Api, + self, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _without_operation_id_delete_oapg( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -13388,7 +23956,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -13396,16 +23968,45 @@ class BaseApi(api_client.Api): class WithoutOperationIdDelete(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def without_operation_id_delete( - self: BaseApi, + self, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def without_operation_id_delete( + self, + skip_deserialization: typing_extensions.Literal[True], + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def without_operation_id_delete( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def without_operation_id_delete( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._without_operation_id_delete_oapg( accept_content_types=accept_content_types, stream=stream, @@ -13417,16 +24018,45 @@ class WithoutOperationIdDelete(BaseApi): class ApiFordelete(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def delete( - self: BaseApi, + self, accept_content_types: typing.Tuple[str] = _all_accept_content_types, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def delete( + self, + skip_deserialization: typing_extensions.Literal[True], + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def delete( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def delete( + self, + accept_content_types: typing.Tuple[str] = _all_accept_content_types, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._without_operation_id_delete_oapg( accept_content_types=accept_content_types, stream=stream, @@ -13584,6 +24214,7 @@ class RESTClientObject(object): elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( method, url, + body=body, fields=fields, encode_multipart=False, preload_content=not stream, @@ -13707,6 +24338,7 @@ import functools import decimal import io import re +import types import typing import uuid @@ -13741,17 +24373,17 @@ class FileIO(io.FileIO): Note: this class is not immutable \\"\\"\\" - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader]): - if isinstance(arg, (io.FileIO, io.BufferedReader)): - if arg.closed: + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader]): + if isinstance(_arg, (io.FileIO, io.BufferedReader)): + if _arg.closed: raise ApiValueError('Invalid file state; file is closed and must be open') - arg.close() - inst = super(FileIO, cls).__new__(cls, arg.name) - super(FileIO, inst).__init__(arg.name) + _arg.close() + inst = super(FileIO, cls).__new__(cls, _arg.name) + super(FileIO, inst).__init__(_arg.name) return inst - raise ApiValueError('FileIO must be passed arg which contains the open file') + raise ApiValueError('FileIO must be passed _arg which contains the open file') - def __init__(self, arg: typing.Union[io.FileIO, io.BufferedReader]): + def __init__(self, _arg: typing.Union[io.FileIO, io.BufferedReader]): pass @@ -13839,14 +24471,27 @@ class ValidationMetadata(frozendict.frozendict): return self.get('validated_path_to_schemas') +def add_deeper_validated_schemas(validation_metadata: ValidationMetadata, path_to_schemas: dict): + # this is called if validation_ran_earlier and current and deeper locations need to be added + current_path_to_item = validation_metadata.path_to_item + other_path_to_schemas = {} + for path_to_item, schemas in validation_metadata.validated_path_to_schemas.items(): + if len(path_to_item) < len(current_path_to_item): + continue + path_begins_with_current_path = path_to_item[:len(current_path_to_item)] == current_path_to_item + if path_begins_with_current_path: + other_path_to_schemas[path_to_item] = schemas + update(path_to_schemas, other_path_to_schemas) + + class Singleton: \\"\\"\\" Enums and singletons are the same - The same instance is returned for a given key of (cls, arg) + The same instance is returned for a given key of (cls, _arg) \\"\\"\\" _instances = {} - def __new__(cls, arg: typing.Any, **kwargs): + def __new__(cls, _arg: typing.Any, **kwargs): \\"\\"\\" cls base classes: BoolClass, NoneClass, str, decimal.Decimal The 3rd key is used in the tuple below for a corner case where an enum contains integer 1 @@ -13854,15 +24499,15 @@ class Singleton: Decimal('1.0') == Decimal('1') But if we omitted the 3rd value in the key, then Decimal('1.0') would be stored as Decimal('1') and json serializing that instance would be '1' rather than the expected '1.0' - Adding the 3rd value, the str of arg ensures that 1.0 -> Decimal('1.0') which is serialized as 1.0 + Adding the 3rd value, the str of _arg ensures that 1.0 -> Decimal('1.0') which is serialized as 1.0 \\"\\"\\" - key = (cls, arg, str(arg)) + key = (cls, _arg, str(_arg)) if key not in cls._instances: - if isinstance(arg, (none_type, bool, BoolClass, NoneClass)): + if isinstance(_arg, (none_type, bool, BoolClass, NoneClass)): inst = super().__new__(cls) cls._instances[key] = inst else: - cls._instances[key] = super().__new__(cls, arg) + cls._instances[key] = super().__new__(cls, _arg) return cls._instances[key] def __repr__(self): @@ -13875,9 +24520,17 @@ class Singleton: return f'<{self.__class__.__name__}: {super().__repr__()}>' +class classproperty: + + def __init__(self, fget): + self.fget = fget + + def __get__(self, owner_self, owner_cls): + return self.fget(owner_cls) + + class NoneClass(Singleton): - @classmethod - @property + @classproperty def NONE(cls): return cls(None) @@ -13886,17 +24539,15 @@ class NoneClass(Singleton): class BoolClass(Singleton): - @classmethod - @property + @classproperty def TRUE(cls): return cls(True) - @classmethod - @property + @classproperty def FALSE(cls): return cls(False) - @functools.cache + @functools.lru_cache() def __bool__(self) -> bool: for key, instance in self._instances.items(): if self is instance: @@ -13935,8 +24586,70 @@ class Schema: the base class of all swagger/openapi schemas/models \\"\\"\\" __inheritable_primitive_types_set = {decimal.Decimal, str, tuple, frozendict.frozendict, FileIO, bytes, BoolClass, NoneClass} + _types: typing.Set[typing.Type] MetaOapg = MetaOapgTyped + @staticmethod + def __get_valid_classes_phrase(input_classes): + \\"\\"\\"Returns a string phrase describing what types are allowed\\"\\"\\" + all_classes = list(input_classes) + all_classes = sorted(all_classes, key=lambda cls: cls.__name__) + all_class_names = [cls.__name__ for cls in all_classes] + if len(all_class_names) == 1: + return \\"is {0}\\".format(all_class_names[0]) + return \\"is one of [{0}]\\".format(\\", \\".join(all_class_names)) + + @staticmethod + def _get_class_oapg(item_cls: typing.Union[types.FunctionType, staticmethod, typing.Type['Schema']]) -> typing.Type['Schema']: + if isinstance(item_cls, types.FunctionType): + # referenced schema + return item_cls() + elif isinstance(item_cls, staticmethod): + # referenced schema + return item_cls.__func__() + return item_cls + + @classmethod + def __type_error_message( + cls, var_value=None, var_name=None, valid_classes=None, key_type=None + ): + \\"\\"\\" + Keyword Args: + var_value (any): the variable which has the type_error + var_name (str): the name of the variable which has the typ error + valid_classes (tuple): the accepted classes for current_item's + value + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a tuple + \\"\\"\\" + key_or_value = \\"value\\" + if key_type: + key_or_value = \\"key\\" + valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) + msg = \\"Invalid type. Required {1} type {2} and \\" \\"passed type was {3}\\".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) + return msg + + @classmethod + def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): + error_msg = cls.__type_error_message( + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type, + ) + return ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type, + ) + @classmethod def _validate_oapg( cls, @@ -13945,21 +24658,8 @@ class Schema: ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: \\"\\"\\" Schema _validate_oapg - Runs all schema validation logic and - returns a dynamic class of different bases depending upon the input - This makes it so: - - the returned instance is always a subclass of our defining schema - - this allows us to check type based on whether an instance is a subclass of a schema - - the returned instance is a serializable type (except for None, True, and False) which are enums - - Use cases: - 1. inheritable type: string/decimal.Decimal/frozendict.frozendict/tuple - 2. singletons: bool/None -> uses the base classes BoolClass/NoneClass - - Required Steps: - 1. verify type of input is valid vs the allowed _types - 2. check validations that are applicable for this type of input - 3. if enums exist, check that the value exists in the enum + All keyword validation except for type checking was done in calling stack frames + If those validations passed, the validated classes are collected in path_to_schemas Returns: path_to_schemas: a map of path to schemas @@ -13969,6 +24669,14 @@ class Schema: ApiTypeError: when the input type is not in the list of allowed spec types \\"\\"\\" base_class = type(arg) + if base_class not in cls._types: + raise cls.__get_type_error( + arg, + validation_metadata.path_to_item, + cls._types, + key_type=False, + ) + path_to_schemas = {validation_metadata.path_to_item: set()} path_to_schemas[validation_metadata.path_to_item].add(cls) path_to_schemas[validation_metadata.path_to_item].add(base_class) @@ -14013,16 +24721,16 @@ class Schema: _validate_oapg returns a key value pair where the key is the path to the item, and the value will be the required manufactured class made out of the matching schemas - 2. value is an instance of the the correct schema type + 2. value is an instance of the correct schema type the value is NOT validated by _validate_oapg, _validate_oapg only checks that the instance is of the correct schema type for this value, _validate_oapg does NOT return an entry for it in _path_to_schemas and in list/dict _get_items_oapg,_get_properties_oapg the value will be directly assigned because value is of the correct type, and validation was run earlier when the instance was created \\"\\"\\" _path_to_schemas = {} - if validation_metadata.validated_path_to_schemas: - update(_path_to_schemas, validation_metadata.validated_path_to_schemas) - if not validation_metadata.validation_ran_earlier(cls): + if validation_metadata.validation_ran_earlier(cls): + add_deeper_validated_schemas(validation_metadata, _path_to_schemas) + else: other_path_to_schemas = cls._validate_oapg(arg, validation_metadata=validation_metadata) update(_path_to_schemas, other_path_to_schemas) # loop through it make a new class for each entry @@ -14039,7 +24747,7 @@ class Schema: \\"\\"\\" cls._process_schema_classes_oapg(schema_classes) enum_schema = any( - hasattr(this_cls, '_enum_value_to_name') for this_cls in schema_classes) + issubclass(this_cls, EnumBase) for this_cls in schema_classes) inheritable_primitive_type = schema_classes.intersection(cls.__inheritable_primitive_types_set) chosen_schema_classes = schema_classes - inheritable_primitive_type suffix = tuple(inheritable_primitive_type) @@ -14127,12 +24835,12 @@ class Schema: def __remove_unsets(kwargs): return {key: val for key, val in kwargs.items() if val is not unset} - def __new__(cls, *args: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): + def __new__(cls, *_args: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): \\"\\"\\" Schema __new__ Args: - args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): the value + _args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): the value kwargs (str, int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): dict values _configuration: contains the Configuration that enables json schema validation keywords like minItems, minLength etc @@ -14141,14 +24849,14 @@ class Schema: are instance properties if they are named normally :( \\"\\"\\" __kwargs = cls.__remove_unsets(kwargs) - if not args and not __kwargs: + if not _args and not __kwargs: raise TypeError( 'No input given. args or kwargs must be given.' ) - if not __kwargs and args and not isinstance(args[0], dict): - __arg = args[0] + if not __kwargs and _args and not isinstance(_args[0], dict): + __arg = _args[0] else: - __arg = cls.__get_input_dict(*args, **__kwargs) + __arg = cls.__get_input_dict(*_args, **__kwargs) __from_server = False __validated_path_to_schemas = {} __arg = cast_to_allowed_types( @@ -14165,7 +24873,7 @@ class Schema: def __init__( self, - *args: typing.Union[ + *_args: typing.Union[ dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[ @@ -14183,17 +24891,33 @@ class Schema: \\"\\"\\" import itertools data_types = ('None', 'FrozenDict', 'Tuple', 'Str', 'Decimal', 'Bool') -[v for v in itertools.combinations(data_types, 2)] +type_to_cls = { + 'None': 'NoneClass', + 'FrozenDict': 'frozendict.frozendict', + 'Tuple': 'tuple', + 'Str': 'str', + 'Decimal': 'decimal.Decimal', + 'Bool': 'BoolClass' +} +cls_tuples = [v for v in itertools.combinations(data_types, 5)] +typed_classes = [f\\"class {''.join(cls_tuple)}Mixin({', '.join(type_to_cls[typ] for typ in cls_tuple)}):\\\\n pass\\" for cls_tuple in cls_tuples] +for cls in typed_classes: + print(cls) +object_classes = [f\\"{''.join(cls_tuple)}Mixin = object\\" for cls_tuple in cls_tuples] +for cls in object_classes: + print(cls) \\"\\"\\" if typing.TYPE_CHECKING: - # qty 1 mixin + # qty 1 NoneMixin = NoneClass FrozenDictMixin = frozendict.frozendict TupleMixin = tuple StrMixin = str DecimalMixin = decimal.Decimal BoolMixin = BoolClass - # qty 2 mixin + BytesMixin = bytes + FileMixin = FileIO + # qty 2 class BinaryMixin(bytes, FileIO): pass class NoneFrozenDictMixin(NoneClass, frozendict.frozendict): @@ -14226,35 +24950,239 @@ if typing.TYPE_CHECKING: pass class DecimalBoolMixin(decimal.Decimal, BoolClass): pass + # qty 3 + class NoneFrozenDictTupleMixin(NoneClass, frozendict.frozendict, tuple): + pass + class NoneFrozenDictStrMixin(NoneClass, frozendict.frozendict, str): + pass + class NoneFrozenDictDecimalMixin(NoneClass, frozendict.frozendict, decimal.Decimal): + pass + class NoneFrozenDictBoolMixin(NoneClass, frozendict.frozendict, BoolClass): + pass + class NoneTupleStrMixin(NoneClass, tuple, str): + pass + class NoneTupleDecimalMixin(NoneClass, tuple, decimal.Decimal): + pass + class NoneTupleBoolMixin(NoneClass, tuple, BoolClass): + pass + class NoneStrDecimalMixin(NoneClass, str, decimal.Decimal): + pass + class NoneStrBoolMixin(NoneClass, str, BoolClass): + pass + class NoneDecimalBoolMixin(NoneClass, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrMixin(frozendict.frozendict, tuple, str): + pass + class FrozenDictTupleDecimalMixin(frozendict.frozendict, tuple, decimal.Decimal): + pass + class FrozenDictTupleBoolMixin(frozendict.frozendict, tuple, BoolClass): + pass + class FrozenDictStrDecimalMixin(frozendict.frozendict, str, decimal.Decimal): + pass + class FrozenDictStrBoolMixin(frozendict.frozendict, str, BoolClass): + pass + class FrozenDictDecimalBoolMixin(frozendict.frozendict, decimal.Decimal, BoolClass): + pass + class TupleStrDecimalMixin(tuple, str, decimal.Decimal): + pass + class TupleStrBoolMixin(tuple, str, BoolClass): + pass + class TupleDecimalBoolMixin(tuple, decimal.Decimal, BoolClass): + pass + class StrDecimalBoolMixin(str, decimal.Decimal, BoolClass): + pass + # qty 4 + class NoneFrozenDictTupleStrMixin(NoneClass, frozendict.frozendict, tuple, str): + pass + class NoneFrozenDictTupleDecimalMixin(NoneClass, frozendict.frozendict, tuple, decimal.Decimal): + pass + class NoneFrozenDictTupleBoolMixin(NoneClass, frozendict.frozendict, tuple, BoolClass): + pass + class NoneFrozenDictStrDecimalMixin(NoneClass, frozendict.frozendict, str, decimal.Decimal): + pass + class NoneFrozenDictStrBoolMixin(NoneClass, frozendict.frozendict, str, BoolClass): + pass + class NoneFrozenDictDecimalBoolMixin(NoneClass, frozendict.frozendict, decimal.Decimal, BoolClass): + pass + class NoneTupleStrDecimalMixin(NoneClass, tuple, str, decimal.Decimal): + pass + class NoneTupleStrBoolMixin(NoneClass, tuple, str, BoolClass): + pass + class NoneTupleDecimalBoolMixin(NoneClass, tuple, decimal.Decimal, BoolClass): + pass + class NoneStrDecimalBoolMixin(NoneClass, str, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrDecimalMixin(frozendict.frozendict, tuple, str, decimal.Decimal): + pass + class FrozenDictTupleStrBoolMixin(frozendict.frozendict, tuple, str, BoolClass): + pass + class FrozenDictTupleDecimalBoolMixin(frozendict.frozendict, tuple, decimal.Decimal, BoolClass): + pass + class FrozenDictStrDecimalBoolMixin(frozendict.frozendict, str, decimal.Decimal, BoolClass): + pass + class TupleStrDecimalBoolMixin(tuple, str, decimal.Decimal, BoolClass): + pass + # qty 5 + class NoneFrozenDictTupleStrDecimalMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal): + pass + class NoneFrozenDictTupleStrBoolMixin(NoneClass, frozendict.frozendict, tuple, str, BoolClass): + pass + class NoneFrozenDictTupleDecimalBoolMixin(NoneClass, frozendict.frozendict, tuple, decimal.Decimal, BoolClass): + pass + class NoneFrozenDictStrDecimalBoolMixin(NoneClass, frozendict.frozendict, str, decimal.Decimal, BoolClass): + pass + class NoneTupleStrDecimalBoolMixin(NoneClass, tuple, str, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrDecimalBoolMixin(frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass): + pass # qty 6 class NoneFrozenDictTupleStrDecimalBoolMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass): pass + # qty 8 + class NoneFrozenDictTupleStrDecimalBoolFileBytesMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass, FileIO, bytes): + pass else: - # qty 1 mixin - NoneMixin = object - FrozenDictMixin = object - TupleMixin = object - StrMixin = object - DecimalMixin = object - BoolMixin = object - # qty 2 mixin - BinaryMixin = object - NoneFrozenDictMixin = object - NoneTupleMixin = object - NoneStrMixin = object - NoneDecimalMixin = object - NoneBoolMixin = object - FrozenDictTupleMixin = object - FrozenDictStrMixin = object - FrozenDictDecimalMixin = object - FrozenDictBoolMixin = object - TupleStrMixin = object - TupleDecimalMixin = object - TupleBoolMixin = object - StrDecimalMixin = object - StrBoolMixin = object - DecimalBoolMixin = object - NoneFrozenDictTupleStrDecimalBoolMixin = object + # qty 1 + class NoneMixin: + _types = {NoneClass} + class FrozenDictMixin: + _types = {frozendict.frozendict} + class TupleMixin: + _types = {tuple} + class StrMixin: + _types = {str} + class DecimalMixin: + _types = {decimal.Decimal} + class BoolMixin: + _types = {BoolClass} + class BytesMixin: + _types = {bytes} + class FileMixin: + _types = {FileIO} + # qty 2 + class BinaryMixin: + _types = {bytes, FileIO} + class NoneFrozenDictMixin: + _types = {NoneClass, frozendict.frozendict} + class NoneTupleMixin: + _types = {NoneClass, tuple} + class NoneStrMixin: + _types = {NoneClass, str} + class NoneDecimalMixin: + _types = {NoneClass, decimal.Decimal} + class NoneBoolMixin: + _types = {NoneClass, BoolClass} + class FrozenDictTupleMixin: + _types = {frozendict.frozendict, tuple} + class FrozenDictStrMixin: + _types = {frozendict.frozendict, str} + class FrozenDictDecimalMixin: + _types = {frozendict.frozendict, decimal.Decimal} + class FrozenDictBoolMixin: + _types = {frozendict.frozendict, BoolClass} + class TupleStrMixin: + _types = {tuple, str} + class TupleDecimalMixin: + _types = {tuple, decimal.Decimal} + class TupleBoolMixin: + _types = {tuple, BoolClass} + class StrDecimalMixin: + _types = {str, decimal.Decimal} + class StrBoolMixin: + _types = {str, BoolClass} + class DecimalBoolMixin: + _types = {decimal.Decimal, BoolClass} + # qty 3 + class NoneFrozenDictTupleMixin: + _types = {NoneClass, frozendict.frozendict, tuple} + class NoneFrozenDictStrMixin: + _types = {NoneClass, frozendict.frozendict, str} + class NoneFrozenDictDecimalMixin: + _types = {NoneClass, frozendict.frozendict, decimal.Decimal} + class NoneFrozenDictBoolMixin: + _types = {NoneClass, frozendict.frozendict, BoolClass} + class NoneTupleStrMixin: + _types = {NoneClass, tuple, str} + class NoneTupleDecimalMixin: + _types = {NoneClass, tuple, decimal.Decimal} + class NoneTupleBoolMixin: + _types = {NoneClass, tuple, BoolClass} + class NoneStrDecimalMixin: + _types = {NoneClass, str, decimal.Decimal} + class NoneStrBoolMixin: + _types = {NoneClass, str, BoolClass} + class NoneDecimalBoolMixin: + _types = {NoneClass, decimal.Decimal, BoolClass} + class FrozenDictTupleStrMixin: + _types = {frozendict.frozendict, tuple, str} + class FrozenDictTupleDecimalMixin: + _types = {frozendict.frozendict, tuple, decimal.Decimal} + class FrozenDictTupleBoolMixin: + _types = {frozendict.frozendict, tuple, BoolClass} + class FrozenDictStrDecimalMixin: + _types = {frozendict.frozendict, str, decimal.Decimal} + class FrozenDictStrBoolMixin: + _types = {frozendict.frozendict, str, BoolClass} + class FrozenDictDecimalBoolMixin: + _types = {frozendict.frozendict, decimal.Decimal, BoolClass} + class TupleStrDecimalMixin: + _types = {tuple, str, decimal.Decimal} + class TupleStrBoolMixin: + _types = {tuple, str, BoolClass} + class TupleDecimalBoolMixin: + _types = {tuple, decimal.Decimal, BoolClass} + class StrDecimalBoolMixin: + _types = {str, decimal.Decimal, BoolClass} + # qty 4 + class NoneFrozenDictTupleStrMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str} + class NoneFrozenDictTupleDecimalMixin: + _types = {NoneClass, frozendict.frozendict, tuple, decimal.Decimal} + class NoneFrozenDictTupleBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, BoolClass} + class NoneFrozenDictStrDecimalMixin: + _types = {NoneClass, frozendict.frozendict, str, decimal.Decimal} + class NoneFrozenDictStrBoolMixin: + _types = {NoneClass, frozendict.frozendict, str, BoolClass} + class NoneFrozenDictDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, decimal.Decimal, BoolClass} + class NoneTupleStrDecimalMixin: + _types = {NoneClass, tuple, str, decimal.Decimal} + class NoneTupleStrBoolMixin: + _types = {NoneClass, tuple, str, BoolClass} + class NoneTupleDecimalBoolMixin: + _types = {NoneClass, tuple, decimal.Decimal, BoolClass} + class NoneStrDecimalBoolMixin: + _types = {NoneClass, str, decimal.Decimal, BoolClass} + class FrozenDictTupleStrDecimalMixin: + _types = {frozendict.frozendict, tuple, str, decimal.Decimal} + class FrozenDictTupleStrBoolMixin: + _types = {frozendict.frozendict, tuple, str, BoolClass} + class FrozenDictTupleDecimalBoolMixin: + _types = {frozendict.frozendict, tuple, decimal.Decimal, BoolClass} + class FrozenDictStrDecimalBoolMixin: + _types = {frozendict.frozendict, str, decimal.Decimal, BoolClass} + class TupleStrDecimalBoolMixin: + _types = {tuple, str, decimal.Decimal, BoolClass} + # qty 5 + class NoneFrozenDictTupleStrDecimalMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal} + class NoneFrozenDictTupleStrBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, BoolClass} + class NoneFrozenDictTupleDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, decimal.Decimal, BoolClass} + class NoneFrozenDictStrDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, str, decimal.Decimal, BoolClass} + class NoneTupleStrDecimalBoolMixin: + _types = {NoneClass, tuple, str, decimal.Decimal, BoolClass} + class FrozenDictTupleStrDecimalBoolMixin: + _types = {frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass} + # qty 6 + class NoneFrozenDictTupleStrDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass} + # qty 8 + class NoneFrozenDictTupleStrDecimalBoolFileBytesMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass, FileIO, bytes} class ValidatorBase: @@ -14276,7 +25204,7 @@ class ValidatorBase: schema_keyword not in configuration._disabled_client_side_validations) @staticmethod - def _raise_validation_errror_message_oapg(value, constraint_msg, constraint_value, path_to_item, additional_txt=\\"\\"): + def _raise_validation_error_message_oapg(value, constraint_msg, constraint_value, path_to_item, additional_txt=\\"\\"): raise ApiValueError( \\"Invalid value \`{value}\`, {constraint_msg} \`{constraint_value}\`{additional_txt} at {path_to_item}\\".format( value=value, @@ -14285,150 +25213,25 @@ class ValidatorBase: additional_txt=additional_txt, path_to_item=path_to_item, ) - ) - - -class Validator(typing.Protocol): - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - pass - - -def SchemaTypeCheckerClsFactory(union_type_cls: typing.Union[typing.Any]) -> Validator: - if typing.get_origin(union_type_cls) is typing.Union: - union_classes = typing.get_args(union_type_cls) - else: - # note: when a union of a single class is passed in, the union disappears - union_classes = tuple([union_type_cls]) - \\"\\"\\" - I want the type hint... union_type_cls - and to use it as a base class but when I do, I get - TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases - \\"\\"\\" - class SchemaTypeChecker: - @staticmethod - def __get_valid_classes_phrase(input_classes): - \\"\\"\\"Returns a string phrase describing what types are allowed\\"\\"\\" - all_classes = list(input_classes) - all_classes = sorted(all_classes, key=lambda cls: cls.__name__) - all_class_names = [cls.__name__ for cls in all_classes] - if len(all_class_names) == 1: - return \\"is {0}\\".format(all_class_names[0]) - return \\"is one of [{0}]\\".format(\\", \\".join(all_class_names)) - - @classmethod - def __type_error_message( - cls, var_value=None, var_name=None, valid_classes=None, key_type=None - ): - \\"\\"\\" - Keyword Args: - var_value (any): the variable which has the type_error - var_name (str): the name of the variable which has the typ error - valid_classes (tuple): the accepted classes for current_item's - value - key_type (bool): False if our value is a value in a dict - True if it is a key in a dict - False if our item is an item in a tuple - \\"\\"\\" - key_or_value = \\"value\\" - if key_type: - key_or_value = \\"key\\" - valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) - msg = \\"Invalid type. Required {1} type {2} and \\" \\"passed type was {3}\\".format( - var_name, - key_or_value, - valid_classes_phrase, - type(var_value).__name__, - ) - return msg - - @classmethod - def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): - error_msg = cls.__type_error_message( - var_name=path_to_item[-1], - var_value=var_value, - valid_classes=valid_classes, - key_type=key_type, - ) - return ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=valid_classes, - key_type=key_type, - ) - - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - \\"\\"\\" - SchemaTypeChecker _validate_oapg - Validates arg's type - \\"\\"\\" - arg_type = type(arg) - if arg_type in union_classes: - return super()._validate_oapg(arg, validation_metadata=validation_metadata) - raise cls.__get_type_error( - arg, - validation_metadata.path_to_item, - union_classes, - key_type=False, - ) - - return SchemaTypeChecker - - -class EnumMakerBase: - pass - - -class EnumMakerInterface(Validator): - @classmethod - @property - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - - -def SchemaEnumMakerClsFactory(enum_value_to_name: typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]) -> EnumMakerInterface: - class SchemaEnumMaker(EnumMakerBase): - @classmethod - @property - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - try: - super_enum_value_to_name = super()._enum_value_to_name - except AttributeError: - return enum_value_to_name - intersection = dict(enum_value_to_name.items() & super_enum_value_to_name.items()) - return intersection - - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - \\"\\"\\" - SchemaEnumMaker _validate_oapg - Validates that arg is in the enum's allowed values - \\"\\"\\" - try: - cls._enum_value_to_name[arg] - except KeyError: - raise ApiValueError(\\"Invalid value {} passed in to {}, {}\\".format(arg, cls, cls._enum_value_to_name)) - return super()._validate_oapg(arg, validation_metadata=validation_metadata) + ) + - return SchemaEnumMaker +class EnumBase: + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: + \\"\\"\\" + EnumBase _validate_oapg + Validates that arg is in the enum's allowed values + \\"\\"\\" + try: + cls.MetaOapg.enum_value_to_name[arg] + except KeyError: + raise ApiValueError(\\"Invalid value {} passed in to {}, allowed_values={}\\".format(arg, cls, cls.MetaOapg.enum_value_to_name.keys())) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class BoolBase: @@ -14496,7 +25299,7 @@ class StrBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('maxLength', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'max_length') and len(arg) > cls.MetaOapg.max_length): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"length must be less than or equal to\\", constraint_value=cls.MetaOapg.max_length, @@ -14506,7 +25309,7 @@ class StrBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('minLength', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'min_length') and len(arg) < cls.MetaOapg.min_length): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"length must be greater than or equal to\\", constraint_value=cls.MetaOapg.min_length, @@ -14521,14 +25324,14 @@ class StrBase(ValidatorBase): if flags != 0: # Don't print the regex flags if the flags are not # specified in the OAS document. - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must match regular expression\\", constraint_value=regex_dict['pattern'], path_to_item=validation_metadata.path_to_item, additional_txt=\\" with flags=\`{}\`\\".format(flags) ) - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must match regular expression\\", constraint_value=regex_dict['pattern'], @@ -14550,9 +25353,9 @@ class StrBase(ValidatorBase): return super()._validate_oapg(arg, validation_metadata=validation_metadata) -class UUIDBase(StrBase): +class UUIDBase: @property - @functools.cache + @functools.lru_cache() def as_uuid_oapg(self) -> uuid.UUID: return uuid.UUID(self) @@ -14616,9 +25419,9 @@ class CustomIsoparser(isoparser): DEFAULT_ISOPARSER = CustomIsoparser() -class DateBase(StrBase): +class DateBase: @property - @functools.cache + @functools.lru_cache() def as_date_oapg(self) -> date: return DEFAULT_ISOPARSER.parse_isodate(self) @@ -14649,7 +25452,7 @@ class DateBase(StrBase): class DateTimeBase: @property - @functools.cache + @functools.lru_cache() def as_datetime_oapg(self) -> datetime: return DEFAULT_ISOPARSER.parse_isodatetime(self) @@ -14678,7 +25481,7 @@ class DateTimeBase: return super()._validate_oapg(arg, validation_metadata=validation_metadata) -class DecimalBase(StrBase): +class DecimalBase: \\"\\"\\" A class for storing decimals that are sent over the wire as strings These schemas must remain based on StrBase rather than NumberBase @@ -14686,7 +25489,7 @@ class DecimalBase(StrBase): \\"\\"\\" @property - @functools.cache + @functools.lru_cache() def as_decimal_oapg(self) -> decimal.Decimal: return decimal.Decimal(self) @@ -14744,7 +25547,7 @@ class NumberBase(ValidatorBase): return self._as_float except AttributeError: if self.as_tuple().exponent >= 0: - raise ApiValueError(f'{self} is not an float') + raise ApiValueError(f'{self} is not a float') self._as_float = float(self) return self._as_float @@ -14761,7 +25564,7 @@ class NumberBase(ValidatorBase): multiple_of_value = cls.MetaOapg.multiple_of if (not (float(arg) / multiple_of_value).is_integer()): # Note 'multipleOf' will be as good as the floating point arithmetic. - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"value must be a multiple of\\", constraint_value=multiple_of_value, @@ -14782,7 +25585,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('exclusiveMaximum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'exclusive_maximum') and arg >= cls.MetaOapg.exclusive_maximum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value less than\\", constraint_value=cls.MetaOapg.exclusive_maximum, @@ -14792,7 +25595,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('maximum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'inclusive_maximum') and arg > cls.MetaOapg.inclusive_maximum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value less than or equal to\\", constraint_value=cls.MetaOapg.inclusive_maximum, @@ -14802,7 +25605,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('exclusiveMinimum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'exclusive_minimum') and arg <= cls.MetaOapg.exclusive_minimum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value greater than\\", constraint_value=cls.MetaOapg.exclusive_maximum, @@ -14812,7 +25615,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('minimum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'inclusive_minimum') and arg < cls.MetaOapg.inclusive_minimum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value greater than or equal to\\", constraint_value=cls.MetaOapg.inclusive_minimum, @@ -14855,6 +25658,7 @@ class ListBase(ValidatorBase): # if we have definitions for an items schema, use it # otherwise accept anything item_cls = getattr(cls.MetaOapg, 'items', UnsetAnyTypeSchema) + item_cls = cls._get_class_oapg(item_cls) path_to_schemas = {} for i, value in enumerate(list_items): item_validation_metadata = ValidationMetadata( @@ -14864,6 +25668,7 @@ class ListBase(ValidatorBase): validated_path_to_schemas=validation_metadata.validated_path_to_schemas ) if item_validation_metadata.validation_ran_earlier(item_cls): + add_deeper_validated_schemas(item_validation_metadata, path_to_schemas) continue other_path_to_schemas = item_cls._validate_oapg( value, validation_metadata=item_validation_metadata) @@ -14879,7 +25684,7 @@ class ListBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('maxItems', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'max_items') and len(arg) > cls.MetaOapg.max_items): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of items must be less than or equal to\\", constraint_value=cls.MetaOapg.max_items, @@ -14889,7 +25694,7 @@ class ListBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('minItems', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'min_items') and len(arg) < cls.MetaOapg.min_items): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of items must be greater than or equal to\\", constraint_value=cls.MetaOapg.min_items, @@ -14900,7 +25705,7 @@ class ListBase(ValidatorBase): hasattr(cls.MetaOapg, 'unique_items') and cls.MetaOapg.unique_items and arg): unique_items = set(arg) if len(arg) > len(unique_items): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"duplicate items were found, and the tuple must not contain duplicates because\\", constraint_value='unique_items==True', @@ -14988,7 +25793,7 @@ class Discriminable: \\"\\"\\" if not hasattr(cls.MetaOapg, 'discriminator'): return None - disc = cls.MetaOapg.discriminator + disc = cls.MetaOapg.discriminator() if disc_property_name not in disc: return None discriminated_cls = disc[disc_property_name].get(disc_payload_value) @@ -15003,21 +25808,24 @@ class Discriminable: ): return None # TODO stop traveling if a cycle is hit - for allof_cls in getattr(cls.MetaOapg, 'all_of', []): - discriminated_cls = allof_cls.get_discriminated_class_oapg( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - for oneof_cls in getattr(cls.MetaOapg, 'one_of', []): - discriminated_cls = oneof_cls.get_discriminated_class_oapg( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - for anyof_cls in getattr(cls.MetaOapg, 'any_of', []): - discriminated_cls = anyof_cls.get_discriminated_class_oapg( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls + if hasattr(cls.MetaOapg, 'all_of'): + for allof_cls in cls.MetaOapg.all_of(): + discriminated_cls = allof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + if hasattr(cls.MetaOapg, 'one_of'): + for oneof_cls in cls.MetaOapg.one_of(): + discriminated_cls = oneof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + if hasattr(cls.MetaOapg, 'any_of'): + for anyof_cls in cls.MetaOapg.any_of(): + discriminated_cls = anyof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls return None @@ -15116,9 +25924,7 @@ class DictBase(Discriminable, ValidatorBase): raise ApiTypeError('Unable to find schema for value={} in class={} at path_to_item={}'.format( value, cls, validation_metadata.path_to_item+(property_name,) )) - if isinstance(schema, classmethod): - # referenced schema, call classmethod property - schema = schema.__func__.fget(properties) + schema = cls._get_class_oapg(schema) arg_validation_metadata = ValidationMetadata( from_server=validation_metadata.from_server, configuration=validation_metadata.configuration, @@ -15126,6 +25932,7 @@ class DictBase(Discriminable, ValidatorBase): validated_path_to_schemas=validation_metadata.validated_path_to_schemas ) if arg_validation_metadata.validation_ran_earlier(schema): + add_deeper_validated_schemas(arg_validation_metadata, path_to_schemas) continue other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata) update(path_to_schemas, other_path_to_schemas) @@ -15142,7 +25949,7 @@ class DictBase(Discriminable, ValidatorBase): if (cls._is_json_validation_enabled_oapg('maxProperties', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'max_properties') and len(arg) > cls.MetaOapg.max_properties): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of properties must be less than or equal to\\", constraint_value=cls.MetaOapg.max_properties, @@ -15152,7 +25959,7 @@ class DictBase(Discriminable, ValidatorBase): if (cls._is_json_validation_enabled_oapg('minProperties', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'min_properties') and len(arg) < cls.MetaOapg.min_properties): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of properties must be greater than or equal to\\", constraint_value=cls.MetaOapg.min_properties, @@ -15189,7 +25996,7 @@ class DictBase(Discriminable, ValidatorBase): other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata) update(_path_to_schemas, other_path_to_schemas) try: - discriminator = cls.MetaOapg.discriminator + discriminator = cls.MetaOapg.discriminator() except AttributeError: return _path_to_schemas # discriminator exists @@ -15214,6 +26021,7 @@ class DictBase(Discriminable, ValidatorBase): validated_path_to_schemas=validation_metadata.validated_path_to_schemas ) if updated_vm.validation_ran_earlier(discriminated_cls): + add_deeper_validated_schemas(updated_vm, _path_to_schemas) return _path_to_schemas other_path_to_schemas = discriminated_cls._validate_oapg(arg, validation_metadata=updated_vm) update(_path_to_schemas, other_path_to_schemas) @@ -15312,18 +26120,11 @@ def cast_to_allowed_types( if isinstance(arg, Schema): # store the already run validations schema_classes = set() - source_schema_was_unset = len(arg.__class__.__bases__) == 2 and UnsetAnyTypeSchema in arg.__class__.__bases__ - if not source_schema_was_unset: - \\"\\"\\" - Do not include UnsetAnyTypeSchema and its base class because - it did not exist in the original spec schema definition - It was added to ensure that all instances are of type Schema and the allowed base types - \\"\\"\\" - for cls in arg.__class__.__bases__: - if cls is Singleton: - # Skip Singleton - continue - schema_classes.add(cls) + for cls in arg.__class__.__bases__: + if cls is Singleton: + # Skip Singleton + continue + schema_classes.add(cls) validated_path_to_schemas[path_to_item] = schema_classes type_error = ApiTypeError(f\\"Invalid type. Required value type is str and passed type was {type(arg)} at {path_to_item}\\") @@ -15374,8 +26175,9 @@ class ComposedBase(Discriminable): @classmethod def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): path_to_schemas = defaultdict(set) - for allof_cls in cls.MetaOapg.all_of: + for allof_cls in cls.MetaOapg.all_of(): if validation_metadata.validation_ran_earlier(allof_cls): + add_deeper_validated_schemas(validation_metadata, path_to_schemas) continue other_path_to_schemas = allof_cls._validate_oapg(arg, validation_metadata=validation_metadata) update(path_to_schemas, other_path_to_schemas) @@ -15390,12 +26192,13 @@ class ComposedBase(Discriminable): ): oneof_classes = [] path_to_schemas = defaultdict(set) - for oneof_cls in cls.MetaOapg.one_of: + for oneof_cls in cls.MetaOapg.one_of(): if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: oneof_classes.append(oneof_cls) continue if validation_metadata.validation_ran_earlier(oneof_cls): oneof_classes.append(oneof_cls) + add_deeper_validated_schemas(validation_metadata, path_to_schemas) continue try: path_to_schemas = oneof_cls._validate_oapg(arg, validation_metadata=validation_metadata) @@ -15414,6 +26217,7 @@ class ComposedBase(Discriminable): \\"Invalid inputs given to generate an instance of {}. Multiple \\" \\"oneOf schemas {} matched the inputs, but a max of one is allowed.\\".format(cls, oneof_classes) ) + # exactly one class matches return path_to_schemas @classmethod @@ -15425,9 +26229,10 @@ class ComposedBase(Discriminable): ): anyof_classes = [] path_to_schemas = defaultdict(set) - for anyof_cls in cls.MetaOapg.any_of: + for anyof_cls in cls.MetaOapg.any_of(): if validation_metadata.validation_ran_earlier(anyof_cls): anyof_classes.append(anyof_cls) + add_deeper_validated_schemas(validation_metadata, path_to_schemas) continue try: @@ -15478,7 +26283,9 @@ class ComposedBase(Discriminable): ) # process composed schema - discriminator = getattr(cls, 'discriminator', None) + discriminator = None + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'discriminator'): + discriminator = cls.MetaOapg.discriminator() discriminated_cls = None if discriminator and arg and isinstance(arg, frozendict.frozendict): disc_property_name = list(discriminator.keys())[0] @@ -15515,8 +26322,9 @@ class ComposedBase(Discriminable): ) update(path_to_schemas, other_path_to_schemas) not_cls = None - if hasattr(cls, 'MetaOapg'): - not_cls = getattr(cls.MetaOapg, 'not_schema', None) + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'not_schema'): + not_cls = cls.MetaOapg.not_schema + not_cls = cls._get_class_oapg(not_cls) if not_cls: other_path_to_schemas = None not_exception = ApiValueError( @@ -15538,13 +26346,13 @@ class ComposedBase(Discriminable): if discriminated_cls is not None and not updated_vm.validation_ran_earlier(discriminated_cls): # TODO use an exception from this package here + add_deeper_validated_schemas(updated_vm, path_to_schemas) assert discriminated_cls in path_to_schemas[updated_vm.path_to_item] return path_to_schemas # DictBase, ListBase, NumberBase, StrBase, BoolBase, NoneBase class ComposedSchema( - SchemaTypeCheckerClsFactory(typing.Union[NoneClass, str, decimal.Decimal, BoolClass, tuple, frozendict.frozendict]), ComposedBase, DictBase, ListBase, @@ -15565,7 +26373,6 @@ class ComposedSchema( class ListSchema( - SchemaTypeCheckerClsFactory(typing.Union[tuple]), ListBase, Schema, TupleMixin @@ -15575,12 +26382,11 @@ class ListSchema( def from_openapi_data_oapg(cls, arg: typing.List[typing.Any], _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[typing.List[typing.Any], typing.Tuple[typing.Any]], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[typing.List[typing.Any], typing.Tuple[typing.Any]], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class NoneSchema( - SchemaTypeCheckerClsFactory(typing.Union[NoneClass]), NoneBase, Schema, NoneMixin @@ -15590,12 +26396,11 @@ class NoneSchema( def from_openapi_data_oapg(cls, arg: None, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: None, **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: None, **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class NumberSchema( - SchemaTypeCheckerClsFactory(typing.Union[decimal.Decimal]), NumberBase, Schema, DecimalMixin @@ -15606,14 +26411,14 @@ class NumberSchema( \\"\\"\\" @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[int, float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + def from_openapi_data_oapg(cls, arg: typing.Union[int, float], _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[decimal.Decimal, int, float], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[decimal.Decimal, int, float], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) -class IntBase(NumberBase): +class IntBase: @property def as_int_oapg(self) -> int: try: @@ -15652,15 +26457,33 @@ class IntSchema(IntBase, NumberSchema): def from_openapi_data_oapg(cls, arg: int, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[decimal.Decimal, int], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[decimal.Decimal, int], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class Int32Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-2147483648) - inclusive_maximum = decimal.Decimal(2147483647) + __inclusive_minimum = decimal.Decimal(-2147483648) + __inclusive_maximum = decimal.Decimal(2147483647) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal) and arg.as_tuple().exponent == 0: + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type int32 at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Int32Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Int32Schema( @@ -15671,10 +26494,28 @@ class Int32Schema( class Int64Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-9223372036854775808) - inclusive_maximum = decimal.Decimal(9223372036854775807) + __inclusive_minimum = decimal.Decimal(-9223372036854775808) + __inclusive_maximum = decimal.Decimal(9223372036854775807) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal) and arg.as_tuple().exponent == 0: + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type int64 at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Int64Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Int64Schema( @@ -15685,10 +26526,28 @@ class Int64Schema( class Float32Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-3.4028234663852886e+38) - inclusive_maximum = decimal.Decimal(3.4028234663852886e+38) + __inclusive_minimum = decimal.Decimal(-3.4028234663852886e+38) + __inclusive_maximum = decimal.Decimal(3.4028234663852886e+38) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type float at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Float32Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Float32Schema( @@ -15697,17 +26556,33 @@ class Float32Schema( ): @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): - # todo check format + def from_openapi_data_oapg(cls, arg: float, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) class Float64Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-1.7976931348623157E+308) - inclusive_maximum = decimal.Decimal(1.7976931348623157E+308) + __inclusive_minimum = decimal.Decimal(-1.7976931348623157E+308) + __inclusive_maximum = decimal.Decimal(1.7976931348623157E+308) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type double at {}\\".format(arg, validation_metadata.path_to_item) + ) + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Float64Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Float64Schema( Float64Base, @@ -15715,13 +26590,12 @@ class Float64Schema( ): @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + def from_openapi_data_oapg(cls, arg: float, _configuration: typing.Optional[Configuration] = None): # todo check format return super().from_openapi_data_oapg(arg, _configuration=_configuration) class StrSchema( - SchemaTypeCheckerClsFactory(typing.Union[str]), StrBase, Schema, StrMixin @@ -15734,34 +26608,34 @@ class StrSchema( \\"\\"\\" @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[str], _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': + def from_openapi_data_oapg(cls, arg: str, _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class UUIDSchema(UUIDBase, StrSchema): - def __new__(cls, arg: typing.Union[str, uuid.UUID], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, uuid.UUID], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class DateSchema(DateBase, StrSchema): - def __new__(cls, arg: typing.Union[str, date], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, date], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class DateTimeSchema(DateTimeBase, StrSchema): - def __new__(cls, arg: typing.Union[str, datetime], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, datetime], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class DecimalSchema(DecimalBase, StrSchema): - def __new__(cls, arg: typing.Union[str], **kwargs: Configuration): + def __new__(cls, _arg: str, **kwargs: Configuration): \\"\\"\\" Note: Decimals may not be passed in because cast_to_allowed_types is only invoked once for payloads which can be simple (str) or complex (dicts or lists with nested values) @@ -15770,23 +26644,23 @@ class DecimalSchema(DecimalBase, StrSchema): if one was using it for a StrSchema (where it should be cast to str) or one is using it for NumberSchema where it should stay as Decimal. \\"\\"\\" - return super().__new__(cls, arg, **kwargs) + return super().__new__(cls, _arg, **kwargs) class BytesSchema( - SchemaTypeCheckerClsFactory(typing.Union[bytes]), Schema, + BytesMixin ): \\"\\"\\" this class will subclass bytes and is immutable \\"\\"\\" - def __new__(cls, arg: typing.Union[bytes], **kwargs: Configuration): - return super(Schema, cls).__new__(cls, arg) + def __new__(cls, _arg: bytes, **kwargs: Configuration): + return super(Schema, cls).__new__(cls, _arg) class FileSchema( - SchemaTypeCheckerClsFactory(typing.Union[FileIO]), Schema, + FileMixin ): \\"\\"\\" This class is NOT immutable @@ -15805,8 +26679,8 @@ class FileSchema( - to be able to preserve file name info \\"\\"\\" - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: Configuration): - return super(Schema, cls).__new__(cls, arg) + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: Configuration): + return super(Schema, cls).__new__(cls, _arg) class BinaryBase: @@ -15814,24 +26688,24 @@ class BinaryBase: class BinarySchema( - SchemaTypeCheckerClsFactory(typing.Union[bytes, FileIO]), ComposedBase, BinaryBase, Schema, BinaryMixin ): class MetaOapg: - one_of = [ - BytesSchema, - FileSchema, - ] + @staticmethod + def one_of(): + return [ + BytesSchema, + FileSchema, + ] - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: Configuration): - return super().__new__(cls, arg) + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: Configuration): + return super().__new__(cls, _arg) class BoolSchema( - SchemaTypeCheckerClsFactory(typing.Union[BoolClass]), BoolBase, Schema, BoolMixin @@ -15841,14 +26715,11 @@ class BoolSchema( def from_openapi_data_oapg(cls, arg: bool, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: bool, **kwargs: ValidationMetadata): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: bool, **kwargs: ValidationMetadata): + return super().__new__(cls, _arg, **kwargs) class AnyTypeSchema( - SchemaTypeCheckerClsFactory( - typing.Union[frozendict.frozendict, tuple, decimal.Decimal, str, BoolClass, NoneClass, bytes, FileIO] - ), DictBase, ListBase, NumberBase, @@ -15856,7 +26727,7 @@ class AnyTypeSchema( BoolBase, NoneBase, Schema, - NoneFrozenDictTupleStrDecimalBoolMixin + NoneFrozenDictTupleStrDecimalBoolFileBytesMixin ): # Python representation of a schema defined as true or {} pass @@ -15881,18 +26752,17 @@ class NotAnyTypeSchema( def __new__( cls, - *args, + *_args, _configuration: typing.Optional[Configuration] = None, ) -> 'NotAnyTypeSchema': return super().__new__( cls, - *args, + *_args, _configuration=_configuration, ) class DictSchema( - SchemaTypeCheckerClsFactory(typing.Union[frozendict.frozendict]), DictBase, Schema, FrozenDictMixin @@ -15901,14 +26771,14 @@ class DictSchema( def from_openapi_data_oapg(cls, arg: typing.Dict[str, typing.Any], _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, *args: typing.Union[dict, frozendict.frozendict], **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): - return super().__new__(cls, *args, **kwargs) + def __new__(cls, *_args: typing.Union[dict, frozendict.frozendict], **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): + return super().__new__(cls, *_args, **kwargs) schema_type_classes = {NoneSchema, DictSchema, ListSchema, NumberSchema, StrSchema, BoolSchema, AnyTypeSchema} -@functools.cache +@functools.lru_cache() def get_new_class( class_name: str, bases: typing.Tuple[typing.Type[typing.Union[Schema, typing.Any]], ...] @@ -15925,8 +26795,7 @@ LOG_CACHE_USAGE = False def log_cache_usage(cache_fn): if LOG_CACHE_USAGE: - print(cache_fn.__name__, cache_fn.cache_info()) -", + print(cache_fn.__name__, cache_fn.cache_info())", "test/test_models/__init__.py": "", "test/test_models/test_api_error.py": "# coding: utf-8 @@ -16049,7 +26918,7 @@ class ApiTestMixin: ) @staticmethod - def headers_for_content_type(content_type: str) -> dict[str, str]: + def headers_for_content_type(content_type: str) -> typing.Dict[str, str]: return {'content-type': content_type} @classmethod @@ -16058,7 +26927,7 @@ class ApiTestMixin: body: typing.Union[str, bytes], status: int = 200, content_type: str = json_content_type, - headers: typing.Optional[dict[str, str]] = None, + headers: typing.Optional[typing.Dict[str, str]] = None, preload_content: bool = True ) -> urllib3.HTTPResponse: if headers is None: @@ -16306,9 +27175,10 @@ def test_hello(name, expected): assert hello(name) == expected ", "tox.ini": "[tox] -envlist = py39 +envlist = py37 [testenv] +passenv = PYTHON_VERSION deps=-r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt @@ -16507,7 +27377,7 @@ test/schemas.py test/test_models/__init__.py tox.ini ", - ".openapi-generator/VERSION": "6.1.0", + ".openapi-generator/VERSION": "6.3.0", ".projen/deps.json": Object { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", "dependencies": Array [ @@ -16683,13 +27553,11 @@ This Python package is automatically generated by the [OpenAPI Generator](https: - API version: 1.0.0 - Package version: 1.0.0 -- Build package: org.openapitools.codegen.languages.PythonExperimentalClientCodegen +- Build package: org.openapitools.codegen.languages.PythonClientCodegen ## Requirements. -Python >=3.9 -v3.9 is needed so one can combine classmethod and property decorators to define -object schema properties as classes +Python >=3.7 ## Migration from other generators like python and python-legacy @@ -16730,6 +27598,16 @@ object schema properties as classes - A type hint is also generated for additionalProperties accessed using this method - So you will need to update you code to use some_instance['optionalProp'] to access optional property and additionalProperty values +8. The location of the api classes has changed + - Api classes are located in your_package.apis.tags.some_api + - This change was made to eliminate redundant code generation + - Legacy generators generated the same endpoint twice if it had > 1 tag on it + - This generator defines an endpoint in one class, then inherits that class to generate + apis by tags and by paths + - This change reduces code and allows quicker run time if you use the path apis + - path apis are at your_package.apis.paths.some_path + - Those apis will only load their needed models, which is less to load than all of the resources needed in a tag api + - So you will need to update your import paths to the api classes ### Why are Oapg and _oapg used in class and method names? Classes can have arbitrarily named properties set on them @@ -16810,7 +27688,7 @@ Please follow the [installation procedure](#installation--usage) and then run th import time import test from pprint import pprint -from test.apis import default_api +from test.apis.tags import default_api # Defining the host is optional and defaults to http://localhost # See configuration.py for a list of all supported configuration parameters. configuration = test.Configuration( @@ -16918,18 +27796,15 @@ This endpoint does not need any parameter. Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -200 | ApiResponseFor200 | Ok +200 | [ApiResponseFor200](#neither.ApiResponseFor200) | Ok -#### ApiResponseFor200 +#### neither.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | Unset | body was not defined | headers | Unset | headers were not defined | - -void (empty response body) - ### Authorization No authorization required @@ -16984,18 +27859,15 @@ This endpoint does not need any parameter. Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -200 | ApiResponseFor200 | Ok +200 | [ApiResponseFor200](#tag1.ApiResponseFor200) | Ok -#### ApiResponseFor200 +#### tag1.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | Unset | body was not defined | headers | Unset | headers were not defined | - -void (empty response body) - ### Authorization No authorization required @@ -17039,18 +27911,15 @@ This endpoint does not need any parameter. Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -200 | ApiResponseFor200 | Ok +200 | [ApiResponseFor200](#tag1_again.ApiResponseFor200) | Ok -#### ApiResponseFor200 +#### tag1_again.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | Unset | body was not defined | headers | Unset | headers were not defined | - -void (empty response body) - ### Authorization No authorization required @@ -17104,18 +27973,15 @@ This endpoint does not need any parameter. Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned -200 | ApiResponseFor200 | Ok +200 | [ApiResponseFor200](#tag2.ApiResponseFor200) | Ok -#### ApiResponseFor200 +#### tag2.ApiResponseFor200 Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | body | Unset | body was not defined | headers | Unset | headers were not defined | - -void (empty response body) - ### Authorization No authorization required @@ -17126,7 +27992,7 @@ No authorization required "git_push.sh": "#!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl \\"minor update\\" \\"gitlab.com\\" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl \\"minor update\\" \\"gitlab.com\\" git_user_id=$1 git_repo_id=$2 @@ -17185,11 +28051,12 @@ git push origin master 2>&1 | grep -v 'To https' "requirements-dev.txt": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". projen==99.99.99 ", - "requirements.txt": "certifi >= 14.05.14 -frozendict >= 2.0.3 -python_dateutil >= 2.5.3 + "requirements.txt": "certifi >= 14.5.14 +frozendict ~= 2.3.4 +python-dateutil ~= 2.7.0 setuptools >= 21.0.0 -urllib3 >= 1.15.1 +typing_extensions ~= 4.3.0 +urllib3 ~= 1.26.7 ", "setup.cfg": "[flake8] max-line-length=99 @@ -17217,10 +28084,12 @@ VERSION = \\"1.0.0\\" # http://pypi.python.org/pypi/setuptools REQUIRES = [ - \\"urllib3 >= 1.15\\", - \\"certifi\\", - \\"python-dateutil\\", - \\"frozendict >= 2.0.3\\", + \\"certifi >= 14.5.14\\", + \\"frozendict ~= 2.3.4\\", + \\"python-dateutil ~= 2.7.0\\", + \\"setuptools >= 21.0.0\\", + \\"typing_extensions ~= 4.3.0\\", + \\"urllib3 ~= 1.26.7\\", ] setup( @@ -17231,7 +28100,7 @@ setup( author_email=\\"team@openapitools.org\\", url=\\"\\", keywords=[\\"OpenAPI\\", \\"OpenAPI-Generator\\", \\"Single Tags Test\\"], - python_requires=\\">=3.9\\", + python_requires=\\">=3.7\\", install_requires=REQUIRES, packages=find_packages(exclude=[\\"test\\", \\"tests\\"]), include_package_data=True, @@ -17273,9 +28142,10 @@ from multiprocessing.pool import ThreadPool import re import tempfile import typing +import typing_extensions import urllib3 from urllib3._collections import HTTPHeaderDict -from urllib.parse import quote +from urllib.parse import urlparse, quote from urllib3.fields import RequestField as RequestFieldBase import frozendict @@ -17305,6 +28175,8 @@ class RequestField(RequestFieldBase): class JSONEncoder(json.JSONEncoder): + compact_separators = (',', ':') + def default(self, obj): if isinstance(obj, str): return str(obj) @@ -17547,7 +28419,7 @@ class StyleFormSerializer(ParameterSerializerBase): prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None ) -> str: if prefix_separator_iterator is None: - prefix_separator_iterator = PrefixSeparatorIterator('?', '&') + prefix_separator_iterator = PrefixSeparatorIterator('', '&') return self._ref6570_expansion( variable_name=name, in_data=in_data, @@ -17576,8 +28448,25 @@ class StyleSimpleSerializer(ParameterSerializerBase): ) +class JSONDetector: + \\"\\"\\" + Works for: + application/json + application/json; charset=UTF-8 + application/json-patch+json + application/geo+json + \\"\\"\\" + __json_content_type_pattern = re.compile(\\"application/[^+]*[+]?(json);?.*\\") + + @classmethod + def _content_type_is_json(cls, content_type: str) -> bool: + if cls.__json_content_type_pattern.match(content_type): + return True + return False + + @dataclass -class ParameterBase: +class ParameterBase(JSONDetector): name: str in_type: ParameterInType required: bool @@ -17604,7 +28493,6 @@ class ParameterBase: } __disallowed_header_names = {'Accept', 'Content-Type', 'Authorization'} _json_encoder = JSONEncoder() - _json_content_type = 'application/json' @classmethod def __verify_style_to_in_type(cls, style: typing.Optional[ParameterStyle], in_type: ParameterInType): @@ -17651,8 +28539,11 @@ class ParameterBase: def _serialize_json( self, - in_data: typing.Union[None, int, float, str, bool, dict, list] + in_data: typing.Union[None, int, float, str, bool, dict, list], + eliminate_whitespace: bool = False ) -> str: + if eliminate_whitespace: + return json.dumps(in_data, separators=self._json_encoder.compact_separators) return json.dumps(in_data) @@ -17747,7 +28638,7 @@ class PathParameter(ParameterBase, StyleSimpleSerializer): for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: + if self._content_type_is_json(content_type): value = self._serialize_json(cast_in_data) return self._to_dict(self.name, value) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -17765,7 +28656,7 @@ class QueryParameter(ParameterBase, StyleFormSerializer): schema: typing.Optional[typing.Type[Schema]] = None, content: typing.Optional[typing.Dict[str, typing.Type[Schema]]] = None ): - used_style = ParameterStyle.FORM if style is None and content is None and schema else style + used_style = ParameterStyle.FORM if style is None else style used_explode = self._get_default_explode(used_style) if explode is None else explode super().__init__( @@ -17828,8 +28719,6 @@ class QueryParameter(ParameterBase, StyleFormSerializer): return self._to_dict(self.name, value) def get_prefix_separator_iterator(self) -> typing.Optional[PrefixSeparatorIterator]: - if not self.schema: - return None if self.style is ParameterStyle.FORM: return PrefixSeparatorIterator('?', '&') elif self.style is ParameterStyle.SPACE_DELIMITED: @@ -17868,12 +28757,17 @@ class QueryParameter(ParameterBase, StyleFormSerializer): elif self.style is ParameterStyle.PIPE_DELIMITED: return self.__serialize_pipe_delimited(cast_in_data, prefix_separator_iterator) # self.content will be length one + if prefix_separator_iterator is None: + prefix_separator_iterator = self.get_prefix_separator_iterator() for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: - value = self._serialize_json(cast_in_data) - return self._to_dict(self.name, value) + if self._content_type_is_json(content_type): + value = self._serialize_json(cast_in_data, eliminate_whitespace=True) + return self._to_dict( + self.name, + next(prefix_separator_iterator) + self.name + '=' + quote(value) + ) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -17932,7 +28826,7 @@ class CookieParameter(ParameterBase, StyleFormSerializer): for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: + if self._content_type_is_json(content_type): value = self._serialize_json(cast_in_data) return self._to_dict(self.name, value) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -17961,7 +28855,7 @@ class HeaderParameter(ParameterBase, StyleSimpleSerializer): ) @staticmethod - def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict[str, str]: + def __to_headers(in_data: typing.Tuple[typing.Tuple[str, str], ...]) -> HTTPHeaderDict: data = tuple(t for t in in_data if t) headers = HTTPHeaderDict() if not data: @@ -17973,7 +28867,7 @@ class HeaderParameter(ParameterBase, StyleSimpleSerializer): self, in_data: typing.Union[ Schema, Decimal, int, float, str, date, datetime, None, bool, list, tuple, dict, frozendict.frozendict] - ) -> HTTPHeaderDict[str, str]: + ) -> HTTPHeaderDict: if self.schema: cast_in_data = self.schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) @@ -17989,7 +28883,7 @@ class HeaderParameter(ParameterBase, StyleSimpleSerializer): for content_type, schema in self.content.items(): cast_in_data = schema(in_data) cast_in_data = self._json_encoder.default(cast_in_data) - if content_type == self._json_content_type: + if self._content_type_is_json(content_type): value = self._serialize_json(cast_in_data) return self.__to_headers(((self.name, value),)) raise NotImplementedError('Serialization of {} has not yet been implemented'.format(content_type)) @@ -18028,14 +28922,14 @@ class MediaType: @dataclass class ApiResponse: response: urllib3.HTTPResponse - body: typing.Union[Unset, Schema] - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset def __init__( self, response: urllib3.HTTPResponse, - body: typing.Union[Unset, typing.Type[Schema]], - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset, + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset ): \\"\\"\\" pycharm needs this to prevent 'Unexpected argument' warnings @@ -18052,23 +28946,6 @@ class ApiResponseWithoutDeserialization(ApiResponse): headers: typing.Union[Unset, typing.List[HeaderParameter]] = unset -class JSONDetector: - \\"\\"\\" - Works for: - application/json - application/json; charset=UTF-8 - application/json-patch+json - application/geo+json - \\"\\"\\" - __json_content_type_pattern = re.compile(\\"application/[^+]*[+]?(json);?.*\\") - - @classmethod - def _content_type_is_json(cls, content_type: str) -> bool: - if cls.__json_content_type_pattern.match(content_type): - return True - return False - - class OpenApiResponse(JSONDetector): __filename_content_disposition_pattern = re.compile('filename=\\"(.+?)\\"') @@ -18089,6 +28966,19 @@ class OpenApiResponse(JSONDetector): # python must be >= 3.9 so we can pass in bytes into json.loads return json.loads(response.data) + @staticmethod + def __file_name_from_response_url(response_url: typing.Optional[str]) -> typing.Optional[str]: + if response_url is None: + return None + url_path = urlparse(response_url).path + if url_path: + path_basename = os.path.basename(url_path) + if path_basename: + _filename, ext = os.path.splitext(path_basename) + if ext: + return path_basename + return None + @classmethod def __file_name_from_content_disposition(cls, content_disposition: typing.Optional[str]) -> typing.Optional[str]: if content_disposition is None: @@ -18108,13 +28998,16 @@ class OpenApiResponse(JSONDetector): a file will be written and returned \\"\\"\\" if response.supports_chunked_reads(): - file_name = self.__file_name_from_content_disposition(response.headers.get('content-disposition')) + file_name = ( + self.__file_name_from_content_disposition(response.headers.get('content-disposition')) + or self.__file_name_from_response_url(response.geturl()) + ) if file_name is None: _fd, path = tempfile.mkstemp() else: path = os.path.join(tempfile.gettempdir(), file_name) - # TODO get file_name from the filename at the end of the url if it exists + with open(path, 'wb') as new_file: chunk_size = 1024 while True: @@ -18156,8 +29049,8 @@ class OpenApiResponse(JSONDetector): if self.content is not None: if content_type not in self.content: raise ApiValueError( - f'Invalid content_type={content_type} returned for response with ' - 'status_code={str(response.status)}' + f\\"Invalid content_type returned. Content_type='{content_type}' was returned \\" + f\\"when only {str(set(self.content))} are defined for status_code={str(response.status)}\\" ) body_schema = self.content[content_type].schema if body_schema is None: @@ -18227,7 +29120,7 @@ class ApiClient: self.pool_threads = pool_threads self.rest_client = rest.RESTClientObject(configuration) - self.default_headers = {} + self.default_headers = HTTPHeaderDict() if header_name is not None: self.default_headers[header_name] = header_value self.cookie = cookie @@ -18284,15 +29177,18 @@ class ApiClient: ) -> urllib3.HTTPResponse: # header parameters - headers = headers or {} - headers.update(self.default_headers) + used_headers = HTTPHeaderDict(self.default_headers) if self.cookie: headers['Cookie'] = self.cookie # auth setting - self.update_params_for_auth(headers, + self.update_params_for_auth(used_headers, auth_settings, resource_path, method, body) + # must happen after cookie setting and auth setting in case user is overriding those + if headers: + used_headers.update(headers) + # request url if host is None: url = self.configuration.host + resource_path @@ -18304,7 +29200,7 @@ class ApiClient: response = self.request( method, url, - headers=headers, + headers=used_headers, fields=fields, body=body, stream=stream, @@ -18497,7 +29393,7 @@ class Api: self.api_client = api_client @staticmethod - def _verify_typed_dict_inputs_oapg(cls: typing.Type[typing.TypedDict], data: typing.Dict[str, typing.Any]): + def _verify_typed_dict_inputs_oapg(cls: typing.Type[typing_extensions.TypedDict], data: typing.Dict[str, typing.Any]): \\"\\"\\" Ensures that: - required keys are present @@ -18569,9 +29465,9 @@ class Api: return host -class SerializedRequestBody(typing.TypedDict, total=False): +class SerializedRequestBody(typing_extensions.TypedDict, total=False): body: typing.Union[str, bytes] - fields: typing.Tuple[typing.Union[RequestField, tuple[str, str]], ...] + fields: typing.Tuple[typing.Union[RequestField, typing.Tuple[str, str]], ...] class RequestBody(StyleFormSerializer, JSONDetector): @@ -18615,24 +29511,24 @@ class RequestBody(StyleFormSerializer, JSONDetector): def __multipart_json_item(self, key: str, value: Schema) -> RequestField: json_value = self.__json_encoder.default(value) - return RequestField(name=key, data=json.dumps(json_value), headers={'Content-Type': 'application/json'}) + request_field = RequestField(name=key, data=json.dumps(json_value)) + request_field.make_multipart(content_type='application/json') + return request_field def __multipart_form_item(self, key: str, value: Schema) -> RequestField: if isinstance(value, str): - return RequestField(name=key, data=str(value), headers={'Content-Type': 'text/plain'}) + request_field = RequestField(name=key, data=str(value)) + request_field.make_multipart(content_type='text/plain') elif isinstance(value, bytes): - return RequestField(name=key, data=value, headers={'Content-Type': 'application/octet-stream'}) + request_field = RequestField(name=key, data=value) + request_field.make_multipart(content_type='application/octet-stream') elif isinstance(value, FileIO): - request_field = RequestField( - name=key, - data=value.read(), - filename=os.path.basename(value.name), - headers={'Content-Type': 'application/octet-stream'} - ) + # TODO use content.encoding to limit allowed content types if they are present + request_field = RequestField.from_tuples(key, (os.path.basename(value.name), value.read())) value.close() - return request_field else: - return self.__multipart_json_item(key=key, value=value) + request_field = self.__multipart_json_item(key=key, value=value) + return request_field def __serialize_multipart_form_data( self, in_data: Schema @@ -18688,7 +29584,7 @@ class RequestBody(StyleFormSerializer, JSONDetector): raise ValueError( f'Unable to serialize {in_data} to application/x-www-form-urlencoded because it is not a dict of data') cast_in_data = self.__json_encoder.default(in_data) - value = self._serialize_form(cast_in_data, name='', explode=True, percent_encode=False) + value = self._serialize_form(cast_in_data, name='', explode=True, percent_encode=True) return dict(body=value) def serialize( @@ -18722,12 +29618,11 @@ class RequestBody(StyleFormSerializer, JSONDetector): return self.__serialize_application_x_www_form_data(cast_in_data) elif content_type == 'application/octet-stream': return self.__serialize_application_octet_stream(cast_in_data) - raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type)) -", + raise NotImplementedError('Serialization has not yet been implemented for {}'.format(content_type))", "test/apis/__init__.py": "# do not import all endpoints into this module because that uses a lot of memory and stack frames # if you need the ability to import all endpoints then import them from # tags, paths, or path_to_api, or tag_to_api", - "test/apis/path_to_api.py": "import typing + "test/apis/path_to_api.py": "import typing_extensions from test.paths import PathValues from test.apis.paths.tag1 import Tag1 @@ -18735,7 +29630,7 @@ from test.apis.paths.tag1_again import Tag1Again from test.apis.paths.tag2 import Tag2 from test.apis.paths.neither import Neither -PathToApi = typing.TypedDict( +PathToApi = typing_extensions.TypedDict( 'PathToApi', { PathValues.TAG1: Tag1, @@ -18790,14 +29685,14 @@ class Tag2( ): pass ", - "test/apis/tag_to_api.py": "import typing + "test/apis/tag_to_api.py": "import typing_extensions from test.apis.tags import TagValues from test.apis.tags.default_api import DefaultApi from test.apis.tags.tag1_api import Tag1Api from test.apis.tags.tag2_api import Tag2Api -TagToApi = typing.TypedDict( +TagToApi = typing_extensions.TypedDict( 'TagToApi', { TagValues.DEFAULT: DefaultApi, @@ -19429,14 +30324,16 @@ class Configuration(object): _default = None - def __init__(self, host=None, - api_key=None, api_key_prefix=None, - username=None, password=None, - discard_unknown_keys=False, - disabled_client_side_validations=\\"\\", - server_index=None, server_variables=None, - server_operation_index=None, server_operation_variables=None, - ): + def __init__( + self, + host=None, + discard_unknown_keys=False, + disabled_client_side_validations=\\"\\", + server_index=None, + server_variables=None, + server_operation_index=None, + server_operation_variables=None, + ): \\"\\"\\"Constructor \\"\\"\\" self._base_path = \\"http://localhost\\" if host is None else host @@ -19454,26 +30351,6 @@ class Configuration(object): \\"\\"\\"Temp file folder for downloading files \\"\\"\\" # Authentication Settings - self.api_key = {} - if api_key: - self.api_key = api_key - \\"\\"\\"dict to store API key(s) - \\"\\"\\" - self.api_key_prefix = {} - if api_key_prefix: - self.api_key_prefix = api_key_prefix - \\"\\"\\"dict to store API prefix (e.g. Bearer) - \\"\\"\\" - self.refresh_api_key_hook = None - \\"\\"\\"function hook to refresh API key if expired - \\"\\"\\" - self.username = username - \\"\\"\\"Username for HTTP basic authentication - \\"\\"\\" - self.password = password - \\"\\"\\"Password for HTTP basic authentication - \\"\\"\\" - self.discard_unknown_keys = discard_unknown_keys self.disabled_client_side_validations = disabled_client_side_validations self.logger = {} \\"\\"\\"Logging Settings @@ -19807,6 +30684,10 @@ class Configuration(object): The version of the OpenAPI document: 1.0.0 Generated by: https://openapi-generator.tech \\"\\"\\" +import dataclasses +import typing + +from urllib3._collections import HTTPHeaderDict class OpenApiException(Exception): @@ -19896,19 +30777,26 @@ class ApiKeyError(OpenApiException, KeyError): super(ApiKeyError, self).__init__(full_msg) -class ApiException(OpenApiException): +T = typing.TypeVar(\\"T\\") - def __init__(self, status=None, reason=None, api_response: 'test.api_client.ApiResponse' = None): - if api_response: - self.status = api_response.response.status - self.reason = api_response.response.reason - self.body = api_response.response.data - self.headers = api_response.response.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + +@dataclasses.dataclass +class ApiException(OpenApiException, typing.Generic[T]): + status: int + reason: str + api_response: typing.Optional[T] = None + + @property + def body(self) -> typing.Union[str, bytes, None]: + if not self.api_response: + return None + return self.api_response.response.data + + @property + def headers(self) -> typing.Optional[HTTPHeaderDict]: + if not self.api_response: + return None + return self.api_response.response.getheaders() def __str__(self): \\"\\"\\"Custom error messages for exception\\"\\"\\" @@ -19948,7 +30836,7 @@ def render_path(path_to_item): # if you have many models here with many references from one model to another this may # raise a RecursionError # to avoid this, import only the models that you directly need like: -# from from test.model.pet import Pet +# from test.model.pet import Pet # or import this package, but before doing it, use: # import sys # sys.setrecursionlimit(n) @@ -19983,6 +30871,7 @@ path = PathValues.NEITHER", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -19992,6 +30881,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -20018,16 +30908,41 @@ _status_code_to_response = { class BaseApi(api_client.Api): + @typing.overload + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _neither_oapg( - self: api_client.Api, + self, + skip_deserialization: typing_extensions.Literal[True], stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -20053,7 +30968,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -20061,15 +30980,41 @@ class BaseApi(api_client.Api): class Neither(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def neither( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def neither( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._neither_oapg( stream=stream, timeout=timeout, @@ -20080,15 +31025,41 @@ class Neither(BaseApi): class ApiForget(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def get( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._neither_oapg( stream=stream, timeout=timeout, @@ -20106,6 +31077,7 @@ class ApiForget(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -20115,25 +31087,63 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 -from test import schemas # noqa: F401 +from test import schemas # noqa: F401 + + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) class BaseApi(api_client.Api): + @typing.overload + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _neither_oapg( - self: api_client.Api, + self, + skip_deserialization: typing_extensions.Literal[True], stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _neither_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -20159,7 +31169,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -20167,15 +31181,41 @@ class BaseApi(api_client.Api): class Neither(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def neither( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def neither( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def neither( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._neither_oapg( stream=stream, timeout=timeout, @@ -20186,15 +31226,41 @@ class Neither(BaseApi): class ApiForget(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def get( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._neither_oapg( stream=stream, timeout=timeout, @@ -20219,6 +31285,7 @@ path = PathValues.TAG1", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -20228,6 +31295,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -20254,16 +31322,41 @@ _status_code_to_response = { class BaseApi(api_client.Api): + @typing.overload + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _tag1_oapg( - self: api_client.Api, + self, + skip_deserialization: typing_extensions.Literal[True], stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -20289,7 +31382,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -20297,15 +31394,41 @@ class BaseApi(api_client.Api): class Tag1(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def tag1( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def tag1( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag1_oapg( stream=stream, timeout=timeout, @@ -20316,15 +31439,41 @@ class Tag1(BaseApi): class ApiForget(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def get( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag1_oapg( stream=stream, timeout=timeout, @@ -20342,6 +31491,7 @@ class ApiForget(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -20351,6 +31501,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -20359,17 +31510,54 @@ from test import schemas # noqa: F401 +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) + + class BaseApi(api_client.Api): + @typing.overload + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _tag1_oapg( - self: api_client.Api, + self, + skip_deserialization: typing_extensions.Literal[True], stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _tag1_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -20395,7 +31583,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -20403,15 +31595,41 @@ class BaseApi(api_client.Api): class Tag1(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def tag1( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + ]: ... + + @typing.overload + def tag1( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag1( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag1_oapg( stream=stream, timeout=timeout, @@ -20422,15 +31640,41 @@ class Tag1(BaseApi): class ApiForget(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def get( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag1_oapg( stream=stream, timeout=timeout, @@ -20455,6 +31699,7 @@ path = PathValues.TAG1AGAIN", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -20464,6 +31709,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -20490,16 +31736,41 @@ _status_code_to_response = { class BaseApi(api_client.Api): + @typing.overload + def _tag1_again_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _tag1_again_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _tag1_again_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization, + ]: ... def _tag1_again_oapg( - self: api_client.Api, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, skip_deserialization: bool = False, - ) -> typing.Union[ - ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -20525,7 +31796,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -20533,15 +31808,41 @@ class BaseApi(api_client.Api): class Tag1Again(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def tag1_again( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def tag1_again( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def tag1_again( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag1_again( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag1_again_oapg( stream=stream, timeout=timeout, @@ -20552,15 +31853,41 @@ class Tag1Again(BaseApi): class ApiForget(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload def get( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag1_again_oapg( stream=stream, timeout=timeout, @@ -20578,6 +31905,7 @@ class ApiForget(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -20587,6 +31915,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -20595,17 +31924,54 @@ from test import schemas # noqa: F401 +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) + + class BaseApi(api_client.Api): + @typing.overload + def _tag1_again_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _tag1_again_oapg( - self: api_client.Api, + self, + skip_deserialization: typing_extensions.Literal[True], stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _tag1_again_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _tag1_again_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -20631,7 +31997,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -20639,15 +32009,41 @@ class BaseApi(api_client.Api): class Tag1Again(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def tag1_again( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def tag1_again( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def tag1_again( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag1_again( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag1_again_oapg( stream=stream, timeout=timeout, @@ -20658,15 +32054,41 @@ class Tag1Again(BaseApi): class ApiForget(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def get( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag1_again_oapg( stream=stream, timeout=timeout, @@ -20691,6 +32113,7 @@ path = PathValues.TAG2", \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -20700,6 +32123,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -20726,16 +32150,41 @@ _status_code_to_response = { class BaseApi(api_client.Api): + @typing.overload + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + @typing.overload def _tag2_oapg( - self: api_client.Api, + self, + skip_deserialization: typing_extensions.Literal[True], stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -20761,7 +32210,11 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response @@ -20769,15 +32222,41 @@ class BaseApi(api_client.Api): class Tag2(BaseApi): # this class is used by api classes that refer to endpoints with operationId fn names + @typing.overload def tag2( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def tag2( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag2_oapg( stream=stream, timeout=timeout, @@ -20788,15 +32267,41 @@ class Tag2(BaseApi): class ApiForget(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def get( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag2_oapg( stream=stream, timeout=timeout, @@ -20814,6 +32319,7 @@ class ApiForget(BaseApi): \\"\\"\\" from dataclasses import dataclass +import typing_extensions import urllib3 from test import api_client, exceptions @@ -20823,6 +32329,7 @@ import functools # noqa: F401 import io # noqa: F401 import re # noqa: F401 import typing # noqa: F401 +import typing_extensions # noqa: F401 import uuid # noqa: F401 import frozendict # noqa: F401 @@ -20831,17 +32338,54 @@ from test import schemas # noqa: F401 +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: schemas.Unset = schemas.unset + headers: schemas.Unset = schemas.unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) + + class BaseApi(api_client.Api): + @typing.overload + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def _tag2_oapg( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + @typing.overload def _tag2_oapg( - self: api_client.Api, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def _tag2_oapg( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): \\"\\"\\" :param skip_deserialization: If true then api_response.response will be set but api_response.body and api_response.headers will not be deserialized into schema @@ -20867,23 +32411,53 @@ class BaseApi(api_client.Api): api_response = api_client.ApiResponseWithoutDeserialization(response=response) if not 200 <= response.status <= 299: - raise exceptions.ApiException(api_response=api_response) + raise exceptions.ApiException( + status=response.status, + reason=response.reason, + api_response=api_response + ) return api_response -class Tag2(BaseApi): - # this class is used by api classes that refer to endpoints with operationId fn names +class Tag2(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + @typing.overload + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def tag2( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + @typing.overload def tag2( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def tag2( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag2_oapg( stream=stream, timeout=timeout, @@ -20894,15 +32468,41 @@ class Tag2(BaseApi): class ApiForget(BaseApi): # this class is used by api classes that refer to endpoints by path and http method names + @typing.overload def get( - self: BaseApi, + self, stream: bool = False, timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, - skip_deserialization: bool = False, + skip_deserialization: typing_extensions.Literal[False] = ..., + ) -> typing.Union[ + ApiResponseFor200, + ]: ... + + @typing.overload + def get( + self, + skip_deserialization: typing_extensions.Literal[True], + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + ) -> api_client.ApiResponseWithoutDeserialization: ... + + @typing.overload + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, - api_client.ApiResponseWithoutDeserialization - ]: + api_client.ApiResponseWithoutDeserialization, + ]: ... + + def get( + self, + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ): return self._tag2_oapg( stream=stream, timeout=timeout, @@ -21059,6 +32659,7 @@ class RESTClientObject(object): elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( method, url, + body=body, fields=fields, encode_multipart=False, preload_content=not stream, @@ -21182,6 +32783,7 @@ import functools import decimal import io import re +import types import typing import uuid @@ -21216,17 +32818,17 @@ class FileIO(io.FileIO): Note: this class is not immutable \\"\\"\\" - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader]): - if isinstance(arg, (io.FileIO, io.BufferedReader)): - if arg.closed: + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader]): + if isinstance(_arg, (io.FileIO, io.BufferedReader)): + if _arg.closed: raise ApiValueError('Invalid file state; file is closed and must be open') - arg.close() - inst = super(FileIO, cls).__new__(cls, arg.name) - super(FileIO, inst).__init__(arg.name) + _arg.close() + inst = super(FileIO, cls).__new__(cls, _arg.name) + super(FileIO, inst).__init__(_arg.name) return inst - raise ApiValueError('FileIO must be passed arg which contains the open file') + raise ApiValueError('FileIO must be passed _arg which contains the open file') - def __init__(self, arg: typing.Union[io.FileIO, io.BufferedReader]): + def __init__(self, _arg: typing.Union[io.FileIO, io.BufferedReader]): pass @@ -21314,14 +32916,27 @@ class ValidationMetadata(frozendict.frozendict): return self.get('validated_path_to_schemas') +def add_deeper_validated_schemas(validation_metadata: ValidationMetadata, path_to_schemas: dict): + # this is called if validation_ran_earlier and current and deeper locations need to be added + current_path_to_item = validation_metadata.path_to_item + other_path_to_schemas = {} + for path_to_item, schemas in validation_metadata.validated_path_to_schemas.items(): + if len(path_to_item) < len(current_path_to_item): + continue + path_begins_with_current_path = path_to_item[:len(current_path_to_item)] == current_path_to_item + if path_begins_with_current_path: + other_path_to_schemas[path_to_item] = schemas + update(path_to_schemas, other_path_to_schemas) + + class Singleton: \\"\\"\\" Enums and singletons are the same - The same instance is returned for a given key of (cls, arg) + The same instance is returned for a given key of (cls, _arg) \\"\\"\\" _instances = {} - def __new__(cls, arg: typing.Any, **kwargs): + def __new__(cls, _arg: typing.Any, **kwargs): \\"\\"\\" cls base classes: BoolClass, NoneClass, str, decimal.Decimal The 3rd key is used in the tuple below for a corner case where an enum contains integer 1 @@ -21329,15 +32944,15 @@ class Singleton: Decimal('1.0') == Decimal('1') But if we omitted the 3rd value in the key, then Decimal('1.0') would be stored as Decimal('1') and json serializing that instance would be '1' rather than the expected '1.0' - Adding the 3rd value, the str of arg ensures that 1.0 -> Decimal('1.0') which is serialized as 1.0 + Adding the 3rd value, the str of _arg ensures that 1.0 -> Decimal('1.0') which is serialized as 1.0 \\"\\"\\" - key = (cls, arg, str(arg)) + key = (cls, _arg, str(_arg)) if key not in cls._instances: - if isinstance(arg, (none_type, bool, BoolClass, NoneClass)): + if isinstance(_arg, (none_type, bool, BoolClass, NoneClass)): inst = super().__new__(cls) cls._instances[key] = inst else: - cls._instances[key] = super().__new__(cls, arg) + cls._instances[key] = super().__new__(cls, _arg) return cls._instances[key] def __repr__(self): @@ -21350,9 +32965,17 @@ class Singleton: return f'<{self.__class__.__name__}: {super().__repr__()}>' +class classproperty: + + def __init__(self, fget): + self.fget = fget + + def __get__(self, owner_self, owner_cls): + return self.fget(owner_cls) + + class NoneClass(Singleton): - @classmethod - @property + @classproperty def NONE(cls): return cls(None) @@ -21361,17 +32984,15 @@ class NoneClass(Singleton): class BoolClass(Singleton): - @classmethod - @property + @classproperty def TRUE(cls): return cls(True) - @classmethod - @property + @classproperty def FALSE(cls): return cls(False) - @functools.cache + @functools.lru_cache() def __bool__(self) -> bool: for key, instance in self._instances.items(): if self is instance: @@ -21410,8 +33031,70 @@ class Schema: the base class of all swagger/openapi schemas/models \\"\\"\\" __inheritable_primitive_types_set = {decimal.Decimal, str, tuple, frozendict.frozendict, FileIO, bytes, BoolClass, NoneClass} + _types: typing.Set[typing.Type] MetaOapg = MetaOapgTyped + @staticmethod + def __get_valid_classes_phrase(input_classes): + \\"\\"\\"Returns a string phrase describing what types are allowed\\"\\"\\" + all_classes = list(input_classes) + all_classes = sorted(all_classes, key=lambda cls: cls.__name__) + all_class_names = [cls.__name__ for cls in all_classes] + if len(all_class_names) == 1: + return \\"is {0}\\".format(all_class_names[0]) + return \\"is one of [{0}]\\".format(\\", \\".join(all_class_names)) + + @staticmethod + def _get_class_oapg(item_cls: typing.Union[types.FunctionType, staticmethod, typing.Type['Schema']]) -> typing.Type['Schema']: + if isinstance(item_cls, types.FunctionType): + # referenced schema + return item_cls() + elif isinstance(item_cls, staticmethod): + # referenced schema + return item_cls.__func__() + return item_cls + + @classmethod + def __type_error_message( + cls, var_value=None, var_name=None, valid_classes=None, key_type=None + ): + \\"\\"\\" + Keyword Args: + var_value (any): the variable which has the type_error + var_name (str): the name of the variable which has the typ error + valid_classes (tuple): the accepted classes for current_item's + value + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a tuple + \\"\\"\\" + key_or_value = \\"value\\" + if key_type: + key_or_value = \\"key\\" + valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) + msg = \\"Invalid type. Required {1} type {2} and \\" \\"passed type was {3}\\".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) + return msg + + @classmethod + def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): + error_msg = cls.__type_error_message( + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type, + ) + return ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type, + ) + @classmethod def _validate_oapg( cls, @@ -21420,21 +33103,8 @@ class Schema: ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: \\"\\"\\" Schema _validate_oapg - Runs all schema validation logic and - returns a dynamic class of different bases depending upon the input - This makes it so: - - the returned instance is always a subclass of our defining schema - - this allows us to check type based on whether an instance is a subclass of a schema - - the returned instance is a serializable type (except for None, True, and False) which are enums - - Use cases: - 1. inheritable type: string/decimal.Decimal/frozendict.frozendict/tuple - 2. singletons: bool/None -> uses the base classes BoolClass/NoneClass - - Required Steps: - 1. verify type of input is valid vs the allowed _types - 2. check validations that are applicable for this type of input - 3. if enums exist, check that the value exists in the enum + All keyword validation except for type checking was done in calling stack frames + If those validations passed, the validated classes are collected in path_to_schemas Returns: path_to_schemas: a map of path to schemas @@ -21444,6 +33114,14 @@ class Schema: ApiTypeError: when the input type is not in the list of allowed spec types \\"\\"\\" base_class = type(arg) + if base_class not in cls._types: + raise cls.__get_type_error( + arg, + validation_metadata.path_to_item, + cls._types, + key_type=False, + ) + path_to_schemas = {validation_metadata.path_to_item: set()} path_to_schemas[validation_metadata.path_to_item].add(cls) path_to_schemas[validation_metadata.path_to_item].add(base_class) @@ -21488,16 +33166,16 @@ class Schema: _validate_oapg returns a key value pair where the key is the path to the item, and the value will be the required manufactured class made out of the matching schemas - 2. value is an instance of the the correct schema type + 2. value is an instance of the correct schema type the value is NOT validated by _validate_oapg, _validate_oapg only checks that the instance is of the correct schema type for this value, _validate_oapg does NOT return an entry for it in _path_to_schemas and in list/dict _get_items_oapg,_get_properties_oapg the value will be directly assigned because value is of the correct type, and validation was run earlier when the instance was created \\"\\"\\" _path_to_schemas = {} - if validation_metadata.validated_path_to_schemas: - update(_path_to_schemas, validation_metadata.validated_path_to_schemas) - if not validation_metadata.validation_ran_earlier(cls): + if validation_metadata.validation_ran_earlier(cls): + add_deeper_validated_schemas(validation_metadata, _path_to_schemas) + else: other_path_to_schemas = cls._validate_oapg(arg, validation_metadata=validation_metadata) update(_path_to_schemas, other_path_to_schemas) # loop through it make a new class for each entry @@ -21514,7 +33192,7 @@ class Schema: \\"\\"\\" cls._process_schema_classes_oapg(schema_classes) enum_schema = any( - hasattr(this_cls, '_enum_value_to_name') for this_cls in schema_classes) + issubclass(this_cls, EnumBase) for this_cls in schema_classes) inheritable_primitive_type = schema_classes.intersection(cls.__inheritable_primitive_types_set) chosen_schema_classes = schema_classes - inheritable_primitive_type suffix = tuple(inheritable_primitive_type) @@ -21602,12 +33280,12 @@ class Schema: def __remove_unsets(kwargs): return {key: val for key, val in kwargs.items() if val is not unset} - def __new__(cls, *args: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): + def __new__(cls, *_args: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema', Unset]): \\"\\"\\" Schema __new__ Args: - args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): the value + _args (int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): the value kwargs (str, int/float/decimal.Decimal/str/list/tuple/dict/frozendict.frozendict/bool/None): dict values _configuration: contains the Configuration that enables json schema validation keywords like minItems, minLength etc @@ -21616,14 +33294,14 @@ class Schema: are instance properties if they are named normally :( \\"\\"\\" __kwargs = cls.__remove_unsets(kwargs) - if not args and not __kwargs: + if not _args and not __kwargs: raise TypeError( 'No input given. args or kwargs must be given.' ) - if not __kwargs and args and not isinstance(args[0], dict): - __arg = args[0] + if not __kwargs and _args and not isinstance(_args[0], dict): + __arg = _args[0] else: - __arg = cls.__get_input_dict(*args, **__kwargs) + __arg = cls.__get_input_dict(*_args, **__kwargs) __from_server = False __validated_path_to_schemas = {} __arg = cast_to_allowed_types( @@ -21640,7 +33318,7 @@ class Schema: def __init__( self, - *args: typing.Union[ + *_args: typing.Union[ dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, 'Schema'], _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Union[ @@ -21658,17 +33336,33 @@ class Schema: \\"\\"\\" import itertools data_types = ('None', 'FrozenDict', 'Tuple', 'Str', 'Decimal', 'Bool') -[v for v in itertools.combinations(data_types, 2)] +type_to_cls = { + 'None': 'NoneClass', + 'FrozenDict': 'frozendict.frozendict', + 'Tuple': 'tuple', + 'Str': 'str', + 'Decimal': 'decimal.Decimal', + 'Bool': 'BoolClass' +} +cls_tuples = [v for v in itertools.combinations(data_types, 5)] +typed_classes = [f\\"class {''.join(cls_tuple)}Mixin({', '.join(type_to_cls[typ] for typ in cls_tuple)}):\\\\n pass\\" for cls_tuple in cls_tuples] +for cls in typed_classes: + print(cls) +object_classes = [f\\"{''.join(cls_tuple)}Mixin = object\\" for cls_tuple in cls_tuples] +for cls in object_classes: + print(cls) \\"\\"\\" if typing.TYPE_CHECKING: - # qty 1 mixin + # qty 1 NoneMixin = NoneClass FrozenDictMixin = frozendict.frozendict TupleMixin = tuple StrMixin = str DecimalMixin = decimal.Decimal BoolMixin = BoolClass - # qty 2 mixin + BytesMixin = bytes + FileMixin = FileIO + # qty 2 class BinaryMixin(bytes, FileIO): pass class NoneFrozenDictMixin(NoneClass, frozendict.frozendict): @@ -21701,35 +33395,239 @@ if typing.TYPE_CHECKING: pass class DecimalBoolMixin(decimal.Decimal, BoolClass): pass + # qty 3 + class NoneFrozenDictTupleMixin(NoneClass, frozendict.frozendict, tuple): + pass + class NoneFrozenDictStrMixin(NoneClass, frozendict.frozendict, str): + pass + class NoneFrozenDictDecimalMixin(NoneClass, frozendict.frozendict, decimal.Decimal): + pass + class NoneFrozenDictBoolMixin(NoneClass, frozendict.frozendict, BoolClass): + pass + class NoneTupleStrMixin(NoneClass, tuple, str): + pass + class NoneTupleDecimalMixin(NoneClass, tuple, decimal.Decimal): + pass + class NoneTupleBoolMixin(NoneClass, tuple, BoolClass): + pass + class NoneStrDecimalMixin(NoneClass, str, decimal.Decimal): + pass + class NoneStrBoolMixin(NoneClass, str, BoolClass): + pass + class NoneDecimalBoolMixin(NoneClass, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrMixin(frozendict.frozendict, tuple, str): + pass + class FrozenDictTupleDecimalMixin(frozendict.frozendict, tuple, decimal.Decimal): + pass + class FrozenDictTupleBoolMixin(frozendict.frozendict, tuple, BoolClass): + pass + class FrozenDictStrDecimalMixin(frozendict.frozendict, str, decimal.Decimal): + pass + class FrozenDictStrBoolMixin(frozendict.frozendict, str, BoolClass): + pass + class FrozenDictDecimalBoolMixin(frozendict.frozendict, decimal.Decimal, BoolClass): + pass + class TupleStrDecimalMixin(tuple, str, decimal.Decimal): + pass + class TupleStrBoolMixin(tuple, str, BoolClass): + pass + class TupleDecimalBoolMixin(tuple, decimal.Decimal, BoolClass): + pass + class StrDecimalBoolMixin(str, decimal.Decimal, BoolClass): + pass + # qty 4 + class NoneFrozenDictTupleStrMixin(NoneClass, frozendict.frozendict, tuple, str): + pass + class NoneFrozenDictTupleDecimalMixin(NoneClass, frozendict.frozendict, tuple, decimal.Decimal): + pass + class NoneFrozenDictTupleBoolMixin(NoneClass, frozendict.frozendict, tuple, BoolClass): + pass + class NoneFrozenDictStrDecimalMixin(NoneClass, frozendict.frozendict, str, decimal.Decimal): + pass + class NoneFrozenDictStrBoolMixin(NoneClass, frozendict.frozendict, str, BoolClass): + pass + class NoneFrozenDictDecimalBoolMixin(NoneClass, frozendict.frozendict, decimal.Decimal, BoolClass): + pass + class NoneTupleStrDecimalMixin(NoneClass, tuple, str, decimal.Decimal): + pass + class NoneTupleStrBoolMixin(NoneClass, tuple, str, BoolClass): + pass + class NoneTupleDecimalBoolMixin(NoneClass, tuple, decimal.Decimal, BoolClass): + pass + class NoneStrDecimalBoolMixin(NoneClass, str, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrDecimalMixin(frozendict.frozendict, tuple, str, decimal.Decimal): + pass + class FrozenDictTupleStrBoolMixin(frozendict.frozendict, tuple, str, BoolClass): + pass + class FrozenDictTupleDecimalBoolMixin(frozendict.frozendict, tuple, decimal.Decimal, BoolClass): + pass + class FrozenDictStrDecimalBoolMixin(frozendict.frozendict, str, decimal.Decimal, BoolClass): + pass + class TupleStrDecimalBoolMixin(tuple, str, decimal.Decimal, BoolClass): + pass + # qty 5 + class NoneFrozenDictTupleStrDecimalMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal): + pass + class NoneFrozenDictTupleStrBoolMixin(NoneClass, frozendict.frozendict, tuple, str, BoolClass): + pass + class NoneFrozenDictTupleDecimalBoolMixin(NoneClass, frozendict.frozendict, tuple, decimal.Decimal, BoolClass): + pass + class NoneFrozenDictStrDecimalBoolMixin(NoneClass, frozendict.frozendict, str, decimal.Decimal, BoolClass): + pass + class NoneTupleStrDecimalBoolMixin(NoneClass, tuple, str, decimal.Decimal, BoolClass): + pass + class FrozenDictTupleStrDecimalBoolMixin(frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass): + pass # qty 6 class NoneFrozenDictTupleStrDecimalBoolMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass): pass + # qty 8 + class NoneFrozenDictTupleStrDecimalBoolFileBytesMixin(NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass, FileIO, bytes): + pass else: - # qty 1 mixin - NoneMixin = object - FrozenDictMixin = object - TupleMixin = object - StrMixin = object - DecimalMixin = object - BoolMixin = object - # qty 2 mixin - BinaryMixin = object - NoneFrozenDictMixin = object - NoneTupleMixin = object - NoneStrMixin = object - NoneDecimalMixin = object - NoneBoolMixin = object - FrozenDictTupleMixin = object - FrozenDictStrMixin = object - FrozenDictDecimalMixin = object - FrozenDictBoolMixin = object - TupleStrMixin = object - TupleDecimalMixin = object - TupleBoolMixin = object - StrDecimalMixin = object - StrBoolMixin = object - DecimalBoolMixin = object - NoneFrozenDictTupleStrDecimalBoolMixin = object + # qty 1 + class NoneMixin: + _types = {NoneClass} + class FrozenDictMixin: + _types = {frozendict.frozendict} + class TupleMixin: + _types = {tuple} + class StrMixin: + _types = {str} + class DecimalMixin: + _types = {decimal.Decimal} + class BoolMixin: + _types = {BoolClass} + class BytesMixin: + _types = {bytes} + class FileMixin: + _types = {FileIO} + # qty 2 + class BinaryMixin: + _types = {bytes, FileIO} + class NoneFrozenDictMixin: + _types = {NoneClass, frozendict.frozendict} + class NoneTupleMixin: + _types = {NoneClass, tuple} + class NoneStrMixin: + _types = {NoneClass, str} + class NoneDecimalMixin: + _types = {NoneClass, decimal.Decimal} + class NoneBoolMixin: + _types = {NoneClass, BoolClass} + class FrozenDictTupleMixin: + _types = {frozendict.frozendict, tuple} + class FrozenDictStrMixin: + _types = {frozendict.frozendict, str} + class FrozenDictDecimalMixin: + _types = {frozendict.frozendict, decimal.Decimal} + class FrozenDictBoolMixin: + _types = {frozendict.frozendict, BoolClass} + class TupleStrMixin: + _types = {tuple, str} + class TupleDecimalMixin: + _types = {tuple, decimal.Decimal} + class TupleBoolMixin: + _types = {tuple, BoolClass} + class StrDecimalMixin: + _types = {str, decimal.Decimal} + class StrBoolMixin: + _types = {str, BoolClass} + class DecimalBoolMixin: + _types = {decimal.Decimal, BoolClass} + # qty 3 + class NoneFrozenDictTupleMixin: + _types = {NoneClass, frozendict.frozendict, tuple} + class NoneFrozenDictStrMixin: + _types = {NoneClass, frozendict.frozendict, str} + class NoneFrozenDictDecimalMixin: + _types = {NoneClass, frozendict.frozendict, decimal.Decimal} + class NoneFrozenDictBoolMixin: + _types = {NoneClass, frozendict.frozendict, BoolClass} + class NoneTupleStrMixin: + _types = {NoneClass, tuple, str} + class NoneTupleDecimalMixin: + _types = {NoneClass, tuple, decimal.Decimal} + class NoneTupleBoolMixin: + _types = {NoneClass, tuple, BoolClass} + class NoneStrDecimalMixin: + _types = {NoneClass, str, decimal.Decimal} + class NoneStrBoolMixin: + _types = {NoneClass, str, BoolClass} + class NoneDecimalBoolMixin: + _types = {NoneClass, decimal.Decimal, BoolClass} + class FrozenDictTupleStrMixin: + _types = {frozendict.frozendict, tuple, str} + class FrozenDictTupleDecimalMixin: + _types = {frozendict.frozendict, tuple, decimal.Decimal} + class FrozenDictTupleBoolMixin: + _types = {frozendict.frozendict, tuple, BoolClass} + class FrozenDictStrDecimalMixin: + _types = {frozendict.frozendict, str, decimal.Decimal} + class FrozenDictStrBoolMixin: + _types = {frozendict.frozendict, str, BoolClass} + class FrozenDictDecimalBoolMixin: + _types = {frozendict.frozendict, decimal.Decimal, BoolClass} + class TupleStrDecimalMixin: + _types = {tuple, str, decimal.Decimal} + class TupleStrBoolMixin: + _types = {tuple, str, BoolClass} + class TupleDecimalBoolMixin: + _types = {tuple, decimal.Decimal, BoolClass} + class StrDecimalBoolMixin: + _types = {str, decimal.Decimal, BoolClass} + # qty 4 + class NoneFrozenDictTupleStrMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str} + class NoneFrozenDictTupleDecimalMixin: + _types = {NoneClass, frozendict.frozendict, tuple, decimal.Decimal} + class NoneFrozenDictTupleBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, BoolClass} + class NoneFrozenDictStrDecimalMixin: + _types = {NoneClass, frozendict.frozendict, str, decimal.Decimal} + class NoneFrozenDictStrBoolMixin: + _types = {NoneClass, frozendict.frozendict, str, BoolClass} + class NoneFrozenDictDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, decimal.Decimal, BoolClass} + class NoneTupleStrDecimalMixin: + _types = {NoneClass, tuple, str, decimal.Decimal} + class NoneTupleStrBoolMixin: + _types = {NoneClass, tuple, str, BoolClass} + class NoneTupleDecimalBoolMixin: + _types = {NoneClass, tuple, decimal.Decimal, BoolClass} + class NoneStrDecimalBoolMixin: + _types = {NoneClass, str, decimal.Decimal, BoolClass} + class FrozenDictTupleStrDecimalMixin: + _types = {frozendict.frozendict, tuple, str, decimal.Decimal} + class FrozenDictTupleStrBoolMixin: + _types = {frozendict.frozendict, tuple, str, BoolClass} + class FrozenDictTupleDecimalBoolMixin: + _types = {frozendict.frozendict, tuple, decimal.Decimal, BoolClass} + class FrozenDictStrDecimalBoolMixin: + _types = {frozendict.frozendict, str, decimal.Decimal, BoolClass} + class TupleStrDecimalBoolMixin: + _types = {tuple, str, decimal.Decimal, BoolClass} + # qty 5 + class NoneFrozenDictTupleStrDecimalMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal} + class NoneFrozenDictTupleStrBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, BoolClass} + class NoneFrozenDictTupleDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, decimal.Decimal, BoolClass} + class NoneFrozenDictStrDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, str, decimal.Decimal, BoolClass} + class NoneTupleStrDecimalBoolMixin: + _types = {NoneClass, tuple, str, decimal.Decimal, BoolClass} + class FrozenDictTupleStrDecimalBoolMixin: + _types = {frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass} + # qty 6 + class NoneFrozenDictTupleStrDecimalBoolMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass} + # qty 8 + class NoneFrozenDictTupleStrDecimalBoolFileBytesMixin: + _types = {NoneClass, frozendict.frozendict, tuple, str, decimal.Decimal, BoolClass, FileIO, bytes} class ValidatorBase: @@ -21751,7 +33649,7 @@ class ValidatorBase: schema_keyword not in configuration._disabled_client_side_validations) @staticmethod - def _raise_validation_errror_message_oapg(value, constraint_msg, constraint_value, path_to_item, additional_txt=\\"\\"): + def _raise_validation_error_message_oapg(value, constraint_msg, constraint_value, path_to_item, additional_txt=\\"\\"): raise ApiValueError( \\"Invalid value \`{value}\`, {constraint_msg} \`{constraint_value}\`{additional_txt} at {path_to_item}\\".format( value=value, @@ -21763,147 +33661,22 @@ class ValidatorBase: ) -class Validator(typing.Protocol): +class EnumBase: @classmethod def _validate_oapg( cls, arg, validation_metadata: ValidationMetadata, ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - pass - - -def SchemaTypeCheckerClsFactory(union_type_cls: typing.Union[typing.Any]) -> Validator: - if typing.get_origin(union_type_cls) is typing.Union: - union_classes = typing.get_args(union_type_cls) - else: - # note: when a union of a single class is passed in, the union disappears - union_classes = tuple([union_type_cls]) - \\"\\"\\" - I want the type hint... union_type_cls - and to use it as a base class but when I do, I get - TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases - \\"\\"\\" - class SchemaTypeChecker: - @staticmethod - def __get_valid_classes_phrase(input_classes): - \\"\\"\\"Returns a string phrase describing what types are allowed\\"\\"\\" - all_classes = list(input_classes) - all_classes = sorted(all_classes, key=lambda cls: cls.__name__) - all_class_names = [cls.__name__ for cls in all_classes] - if len(all_class_names) == 1: - return \\"is {0}\\".format(all_class_names[0]) - return \\"is one of [{0}]\\".format(\\", \\".join(all_class_names)) - - @classmethod - def __type_error_message( - cls, var_value=None, var_name=None, valid_classes=None, key_type=None - ): - \\"\\"\\" - Keyword Args: - var_value (any): the variable which has the type_error - var_name (str): the name of the variable which has the typ error - valid_classes (tuple): the accepted classes for current_item's - value - key_type (bool): False if our value is a value in a dict - True if it is a key in a dict - False if our item is an item in a tuple - \\"\\"\\" - key_or_value = \\"value\\" - if key_type: - key_or_value = \\"key\\" - valid_classes_phrase = cls.__get_valid_classes_phrase(valid_classes) - msg = \\"Invalid type. Required {1} type {2} and \\" \\"passed type was {3}\\".format( - var_name, - key_or_value, - valid_classes_phrase, - type(var_value).__name__, - ) - return msg - - @classmethod - def __get_type_error(cls, var_value, path_to_item, valid_classes, key_type=False): - error_msg = cls.__type_error_message( - var_name=path_to_item[-1], - var_value=var_value, - valid_classes=valid_classes, - key_type=key_type, - ) - return ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=valid_classes, - key_type=key_type, - ) - - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - \\"\\"\\" - SchemaTypeChecker _validate_oapg - Validates arg's type - \\"\\"\\" - arg_type = type(arg) - if arg_type in union_classes: - return super()._validate_oapg(arg, validation_metadata=validation_metadata) - raise cls.__get_type_error( - arg, - validation_metadata.path_to_item, - union_classes, - key_type=False, - ) - - return SchemaTypeChecker - - -class EnumMakerBase: - pass - - -class EnumMakerInterface(Validator): - @classmethod - @property - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - - -def SchemaEnumMakerClsFactory(enum_value_to_name: typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]) -> EnumMakerInterface: - class SchemaEnumMaker(EnumMakerBase): - @classmethod - @property - def _enum_value_to_name( - cls - ) -> typing.Dict[typing.Union[str, decimal.Decimal, bool, none_type], str]: - pass - try: - super_enum_value_to_name = super()._enum_value_to_name - except AttributeError: - return enum_value_to_name - intersection = dict(enum_value_to_name.items() & super_enum_value_to_name.items()) - return intersection - - @classmethod - def _validate_oapg( - cls, - arg, - validation_metadata: ValidationMetadata, - ) -> typing.Dict[typing.Tuple[typing.Union[str, int], ...], typing.Set[typing.Union['Schema', str, decimal.Decimal, BoolClass, NoneClass, frozendict.frozendict, tuple]]]: - \\"\\"\\" - SchemaEnumMaker _validate_oapg - Validates that arg is in the enum's allowed values - \\"\\"\\" - try: - cls._enum_value_to_name[arg] - except KeyError: - raise ApiValueError(\\"Invalid value {} passed in to {}, {}\\".format(arg, cls, cls._enum_value_to_name)) - return super()._validate_oapg(arg, validation_metadata=validation_metadata) - - return SchemaEnumMaker + \\"\\"\\" + EnumBase _validate_oapg + Validates that arg is in the enum's allowed values + \\"\\"\\" + try: + cls.MetaOapg.enum_value_to_name[arg] + except KeyError: + raise ApiValueError(\\"Invalid value {} passed in to {}, allowed_values={}\\".format(arg, cls, cls.MetaOapg.enum_value_to_name.keys())) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class BoolBase: @@ -21971,7 +33744,7 @@ class StrBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('maxLength', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'max_length') and len(arg) > cls.MetaOapg.max_length): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"length must be less than or equal to\\", constraint_value=cls.MetaOapg.max_length, @@ -21981,7 +33754,7 @@ class StrBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('minLength', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'min_length') and len(arg) < cls.MetaOapg.min_length): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"length must be greater than or equal to\\", constraint_value=cls.MetaOapg.min_length, @@ -21996,14 +33769,14 @@ class StrBase(ValidatorBase): if flags != 0: # Don't print the regex flags if the flags are not # specified in the OAS document. - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must match regular expression\\", constraint_value=regex_dict['pattern'], path_to_item=validation_metadata.path_to_item, additional_txt=\\" with flags=\`{}\`\\".format(flags) ) - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must match regular expression\\", constraint_value=regex_dict['pattern'], @@ -22025,9 +33798,9 @@ class StrBase(ValidatorBase): return super()._validate_oapg(arg, validation_metadata=validation_metadata) -class UUIDBase(StrBase): +class UUIDBase: @property - @functools.cache + @functools.lru_cache() def as_uuid_oapg(self) -> uuid.UUID: return uuid.UUID(self) @@ -22091,9 +33864,9 @@ class CustomIsoparser(isoparser): DEFAULT_ISOPARSER = CustomIsoparser() -class DateBase(StrBase): +class DateBase: @property - @functools.cache + @functools.lru_cache() def as_date_oapg(self) -> date: return DEFAULT_ISOPARSER.parse_isodate(self) @@ -22124,7 +33897,7 @@ class DateBase(StrBase): class DateTimeBase: @property - @functools.cache + @functools.lru_cache() def as_datetime_oapg(self) -> datetime: return DEFAULT_ISOPARSER.parse_isodatetime(self) @@ -22153,7 +33926,7 @@ class DateTimeBase: return super()._validate_oapg(arg, validation_metadata=validation_metadata) -class DecimalBase(StrBase): +class DecimalBase: \\"\\"\\" A class for storing decimals that are sent over the wire as strings These schemas must remain based on StrBase rather than NumberBase @@ -22161,7 +33934,7 @@ class DecimalBase(StrBase): \\"\\"\\" @property - @functools.cache + @functools.lru_cache() def as_decimal_oapg(self) -> decimal.Decimal: return decimal.Decimal(self) @@ -22219,7 +33992,7 @@ class NumberBase(ValidatorBase): return self._as_float except AttributeError: if self.as_tuple().exponent >= 0: - raise ApiValueError(f'{self} is not an float') + raise ApiValueError(f'{self} is not a float') self._as_float = float(self) return self._as_float @@ -22236,7 +34009,7 @@ class NumberBase(ValidatorBase): multiple_of_value = cls.MetaOapg.multiple_of if (not (float(arg) / multiple_of_value).is_integer()): # Note 'multipleOf' will be as good as the floating point arithmetic. - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"value must be a multiple of\\", constraint_value=multiple_of_value, @@ -22257,7 +34030,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('exclusiveMaximum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'exclusive_maximum') and arg >= cls.MetaOapg.exclusive_maximum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value less than\\", constraint_value=cls.MetaOapg.exclusive_maximum, @@ -22267,7 +34040,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('maximum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'inclusive_maximum') and arg > cls.MetaOapg.inclusive_maximum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value less than or equal to\\", constraint_value=cls.MetaOapg.inclusive_maximum, @@ -22277,7 +34050,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('exclusiveMinimum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'exclusive_minimum') and arg <= cls.MetaOapg.exclusive_minimum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value greater than\\", constraint_value=cls.MetaOapg.exclusive_maximum, @@ -22287,7 +34060,7 @@ class NumberBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('minimum', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'inclusive_minimum') and arg < cls.MetaOapg.inclusive_minimum): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"must be a value greater than or equal to\\", constraint_value=cls.MetaOapg.inclusive_minimum, @@ -22330,6 +34103,7 @@ class ListBase(ValidatorBase): # if we have definitions for an items schema, use it # otherwise accept anything item_cls = getattr(cls.MetaOapg, 'items', UnsetAnyTypeSchema) + item_cls = cls._get_class_oapg(item_cls) path_to_schemas = {} for i, value in enumerate(list_items): item_validation_metadata = ValidationMetadata( @@ -22339,6 +34113,7 @@ class ListBase(ValidatorBase): validated_path_to_schemas=validation_metadata.validated_path_to_schemas ) if item_validation_metadata.validation_ran_earlier(item_cls): + add_deeper_validated_schemas(item_validation_metadata, path_to_schemas) continue other_path_to_schemas = item_cls._validate_oapg( value, validation_metadata=item_validation_metadata) @@ -22354,7 +34129,7 @@ class ListBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('maxItems', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'max_items') and len(arg) > cls.MetaOapg.max_items): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of items must be less than or equal to\\", constraint_value=cls.MetaOapg.max_items, @@ -22364,7 +34139,7 @@ class ListBase(ValidatorBase): if (cls._is_json_validation_enabled_oapg('minItems', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'min_items') and len(arg) < cls.MetaOapg.min_items): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of items must be greater than or equal to\\", constraint_value=cls.MetaOapg.min_items, @@ -22375,7 +34150,7 @@ class ListBase(ValidatorBase): hasattr(cls.MetaOapg, 'unique_items') and cls.MetaOapg.unique_items and arg): unique_items = set(arg) if len(arg) > len(unique_items): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"duplicate items were found, and the tuple must not contain duplicates because\\", constraint_value='unique_items==True', @@ -22463,7 +34238,7 @@ class Discriminable: \\"\\"\\" if not hasattr(cls.MetaOapg, 'discriminator'): return None - disc = cls.MetaOapg.discriminator + disc = cls.MetaOapg.discriminator() if disc_property_name not in disc: return None discriminated_cls = disc[disc_property_name].get(disc_payload_value) @@ -22478,21 +34253,24 @@ class Discriminable: ): return None # TODO stop traveling if a cycle is hit - for allof_cls in getattr(cls.MetaOapg, 'all_of', []): - discriminated_cls = allof_cls.get_discriminated_class_oapg( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - for oneof_cls in getattr(cls.MetaOapg, 'one_of', []): - discriminated_cls = oneof_cls.get_discriminated_class_oapg( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls - for anyof_cls in getattr(cls.MetaOapg, 'any_of', []): - discriminated_cls = anyof_cls.get_discriminated_class_oapg( - disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) - if discriminated_cls is not None: - return discriminated_cls + if hasattr(cls.MetaOapg, 'all_of'): + for allof_cls in cls.MetaOapg.all_of(): + discriminated_cls = allof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + if hasattr(cls.MetaOapg, 'one_of'): + for oneof_cls in cls.MetaOapg.one_of(): + discriminated_cls = oneof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls + if hasattr(cls.MetaOapg, 'any_of'): + for anyof_cls in cls.MetaOapg.any_of(): + discriminated_cls = anyof_cls.get_discriminated_class_oapg( + disc_property_name=disc_property_name, disc_payload_value=disc_payload_value) + if discriminated_cls is not None: + return discriminated_cls return None @@ -22591,9 +34369,7 @@ class DictBase(Discriminable, ValidatorBase): raise ApiTypeError('Unable to find schema for value={} in class={} at path_to_item={}'.format( value, cls, validation_metadata.path_to_item+(property_name,) )) - if isinstance(schema, classmethod): - # referenced schema, call classmethod property - schema = schema.__func__.fget(properties) + schema = cls._get_class_oapg(schema) arg_validation_metadata = ValidationMetadata( from_server=validation_metadata.from_server, configuration=validation_metadata.configuration, @@ -22601,6 +34377,7 @@ class DictBase(Discriminable, ValidatorBase): validated_path_to_schemas=validation_metadata.validated_path_to_schemas ) if arg_validation_metadata.validation_ran_earlier(schema): + add_deeper_validated_schemas(arg_validation_metadata, path_to_schemas) continue other_path_to_schemas = schema._validate_oapg(value, validation_metadata=arg_validation_metadata) update(path_to_schemas, other_path_to_schemas) @@ -22617,7 +34394,7 @@ class DictBase(Discriminable, ValidatorBase): if (cls._is_json_validation_enabled_oapg('maxProperties', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'max_properties') and len(arg) > cls.MetaOapg.max_properties): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of properties must be less than or equal to\\", constraint_value=cls.MetaOapg.max_properties, @@ -22627,7 +34404,7 @@ class DictBase(Discriminable, ValidatorBase): if (cls._is_json_validation_enabled_oapg('minProperties', validation_metadata.configuration) and hasattr(cls.MetaOapg, 'min_properties') and len(arg) < cls.MetaOapg.min_properties): - cls._raise_validation_errror_message_oapg( + cls._raise_validation_error_message_oapg( value=arg, constraint_msg=\\"number of properties must be greater than or equal to\\", constraint_value=cls.MetaOapg.min_properties, @@ -22664,7 +34441,7 @@ class DictBase(Discriminable, ValidatorBase): other_path_to_schemas = cls.__validate_args(arg, validation_metadata=validation_metadata) update(_path_to_schemas, other_path_to_schemas) try: - discriminator = cls.MetaOapg.discriminator + discriminator = cls.MetaOapg.discriminator() except AttributeError: return _path_to_schemas # discriminator exists @@ -22689,6 +34466,7 @@ class DictBase(Discriminable, ValidatorBase): validated_path_to_schemas=validation_metadata.validated_path_to_schemas ) if updated_vm.validation_ran_earlier(discriminated_cls): + add_deeper_validated_schemas(updated_vm, _path_to_schemas) return _path_to_schemas other_path_to_schemas = discriminated_cls._validate_oapg(arg, validation_metadata=updated_vm) update(_path_to_schemas, other_path_to_schemas) @@ -22787,18 +34565,11 @@ def cast_to_allowed_types( if isinstance(arg, Schema): # store the already run validations schema_classes = set() - source_schema_was_unset = len(arg.__class__.__bases__) == 2 and UnsetAnyTypeSchema in arg.__class__.__bases__ - if not source_schema_was_unset: - \\"\\"\\" - Do not include UnsetAnyTypeSchema and its base class because - it did not exist in the original spec schema definition - It was added to ensure that all instances are of type Schema and the allowed base types - \\"\\"\\" - for cls in arg.__class__.__bases__: - if cls is Singleton: - # Skip Singleton - continue - schema_classes.add(cls) + for cls in arg.__class__.__bases__: + if cls is Singleton: + # Skip Singleton + continue + schema_classes.add(cls) validated_path_to_schemas[path_to_item] = schema_classes type_error = ApiTypeError(f\\"Invalid type. Required value type is str and passed type was {type(arg)} at {path_to_item}\\") @@ -22849,8 +34620,9 @@ class ComposedBase(Discriminable): @classmethod def __get_allof_classes(cls, arg, validation_metadata: ValidationMetadata): path_to_schemas = defaultdict(set) - for allof_cls in cls.MetaOapg.all_of: + for allof_cls in cls.MetaOapg.all_of(): if validation_metadata.validation_ran_earlier(allof_cls): + add_deeper_validated_schemas(validation_metadata, path_to_schemas) continue other_path_to_schemas = allof_cls._validate_oapg(arg, validation_metadata=validation_metadata) update(path_to_schemas, other_path_to_schemas) @@ -22865,12 +34637,13 @@ class ComposedBase(Discriminable): ): oneof_classes = [] path_to_schemas = defaultdict(set) - for oneof_cls in cls.MetaOapg.one_of: + for oneof_cls in cls.MetaOapg.one_of(): if oneof_cls in path_to_schemas[validation_metadata.path_to_item]: oneof_classes.append(oneof_cls) continue if validation_metadata.validation_ran_earlier(oneof_cls): oneof_classes.append(oneof_cls) + add_deeper_validated_schemas(validation_metadata, path_to_schemas) continue try: path_to_schemas = oneof_cls._validate_oapg(arg, validation_metadata=validation_metadata) @@ -22889,6 +34662,7 @@ class ComposedBase(Discriminable): \\"Invalid inputs given to generate an instance of {}. Multiple \\" \\"oneOf schemas {} matched the inputs, but a max of one is allowed.\\".format(cls, oneof_classes) ) + # exactly one class matches return path_to_schemas @classmethod @@ -22900,9 +34674,10 @@ class ComposedBase(Discriminable): ): anyof_classes = [] path_to_schemas = defaultdict(set) - for anyof_cls in cls.MetaOapg.any_of: + for anyof_cls in cls.MetaOapg.any_of(): if validation_metadata.validation_ran_earlier(anyof_cls): anyof_classes.append(anyof_cls) + add_deeper_validated_schemas(validation_metadata, path_to_schemas) continue try: @@ -22953,7 +34728,9 @@ class ComposedBase(Discriminable): ) # process composed schema - discriminator = getattr(cls, 'discriminator', None) + discriminator = None + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'discriminator'): + discriminator = cls.MetaOapg.discriminator() discriminated_cls = None if discriminator and arg and isinstance(arg, frozendict.frozendict): disc_property_name = list(discriminator.keys())[0] @@ -22990,8 +34767,9 @@ class ComposedBase(Discriminable): ) update(path_to_schemas, other_path_to_schemas) not_cls = None - if hasattr(cls, 'MetaOapg'): - not_cls = getattr(cls.MetaOapg, 'not_schema', None) + if hasattr(cls, 'MetaOapg') and hasattr(cls.MetaOapg, 'not_schema'): + not_cls = cls.MetaOapg.not_schema + not_cls = cls._get_class_oapg(not_cls) if not_cls: other_path_to_schemas = None not_exception = ApiValueError( @@ -23013,13 +34791,13 @@ class ComposedBase(Discriminable): if discriminated_cls is not None and not updated_vm.validation_ran_earlier(discriminated_cls): # TODO use an exception from this package here + add_deeper_validated_schemas(updated_vm, path_to_schemas) assert discriminated_cls in path_to_schemas[updated_vm.path_to_item] return path_to_schemas # DictBase, ListBase, NumberBase, StrBase, BoolBase, NoneBase class ComposedSchema( - SchemaTypeCheckerClsFactory(typing.Union[NoneClass, str, decimal.Decimal, BoolClass, tuple, frozendict.frozendict]), ComposedBase, DictBase, ListBase, @@ -23040,7 +34818,6 @@ class ComposedSchema( class ListSchema( - SchemaTypeCheckerClsFactory(typing.Union[tuple]), ListBase, Schema, TupleMixin @@ -23050,12 +34827,11 @@ class ListSchema( def from_openapi_data_oapg(cls, arg: typing.List[typing.Any], _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[typing.List[typing.Any], typing.Tuple[typing.Any]], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[typing.List[typing.Any], typing.Tuple[typing.Any]], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class NoneSchema( - SchemaTypeCheckerClsFactory(typing.Union[NoneClass]), NoneBase, Schema, NoneMixin @@ -23065,12 +34841,11 @@ class NoneSchema( def from_openapi_data_oapg(cls, arg: None, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: None, **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: None, **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class NumberSchema( - SchemaTypeCheckerClsFactory(typing.Union[decimal.Decimal]), NumberBase, Schema, DecimalMixin @@ -23081,14 +34856,14 @@ class NumberSchema( \\"\\"\\" @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[int, float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + def from_openapi_data_oapg(cls, arg: typing.Union[int, float], _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[decimal.Decimal, int, float], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[decimal.Decimal, int, float], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) -class IntBase(NumberBase): +class IntBase: @property def as_int_oapg(self) -> int: try: @@ -23127,15 +34902,33 @@ class IntSchema(IntBase, NumberSchema): def from_openapi_data_oapg(cls, arg: int, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[decimal.Decimal, int], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[decimal.Decimal, int], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class Int32Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-2147483648) - inclusive_maximum = decimal.Decimal(2147483647) + __inclusive_minimum = decimal.Decimal(-2147483648) + __inclusive_maximum = decimal.Decimal(2147483647) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal) and arg.as_tuple().exponent == 0: + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type int32 at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Int32Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Int32Schema( @@ -23146,10 +34939,28 @@ class Int32Schema( class Int64Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-9223372036854775808) - inclusive_maximum = decimal.Decimal(9223372036854775807) + __inclusive_minimum = decimal.Decimal(-9223372036854775808) + __inclusive_maximum = decimal.Decimal(9223372036854775807) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal) and arg.as_tuple().exponent == 0: + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type int64 at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Int64Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Int64Schema( @@ -23160,10 +34971,28 @@ class Int64Schema( class Float32Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-3.4028234663852886e+38) - inclusive_maximum = decimal.Decimal(3.4028234663852886e+38) + __inclusive_minimum = decimal.Decimal(-3.4028234663852886e+38) + __inclusive_maximum = decimal.Decimal(3.4028234663852886e+38) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type float at {}\\".format(arg, validation_metadata.path_to_item) + ) + + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Float32Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Float32Schema( @@ -23172,17 +35001,33 @@ class Float32Schema( ): @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): - # todo check format + def from_openapi_data_oapg(cls, arg: float, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) class Float64Base: - # TODO make this run even if the inheriting class defines these - class MetaOapg: - inclusive_minimum = decimal.Decimal(-1.7976931348623157E+308) - inclusive_maximum = decimal.Decimal(1.7976931348623157E+308) + __inclusive_minimum = decimal.Decimal(-1.7976931348623157E+308) + __inclusive_maximum = decimal.Decimal(1.7976931348623157E+308) + + @classmethod + def __validate_format(cls, arg: typing.Optional[decimal.Decimal], validation_metadata: ValidationMetadata): + if isinstance(arg, decimal.Decimal): + if not cls.__inclusive_minimum <= arg <= cls.__inclusive_maximum: + raise ApiValueError( + \\"Invalid value '{}' for type double at {}\\".format(arg, validation_metadata.path_to_item) + ) + @classmethod + def _validate_oapg( + cls, + arg, + validation_metadata: ValidationMetadata, + ): + \\"\\"\\" + Float64Base _validate_oapg + \\"\\"\\" + cls.__validate_format(arg, validation_metadata=validation_metadata) + return super()._validate_oapg(arg, validation_metadata=validation_metadata) class Float64Schema( Float64Base, @@ -23190,13 +35035,12 @@ class Float64Schema( ): @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[float, decimal.Decimal], _configuration: typing.Optional[Configuration] = None): + def from_openapi_data_oapg(cls, arg: float, _configuration: typing.Optional[Configuration] = None): # todo check format return super().from_openapi_data_oapg(arg, _configuration=_configuration) class StrSchema( - SchemaTypeCheckerClsFactory(typing.Union[str]), StrBase, Schema, StrMixin @@ -23209,34 +35053,34 @@ class StrSchema( \\"\\"\\" @classmethod - def from_openapi_data_oapg(cls, arg: typing.Union[str], _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': + def from_openapi_data_oapg(cls, arg: str, _configuration: typing.Optional[Configuration] = None) -> 'StrSchema': return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, date, datetime, uuid.UUID], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class UUIDSchema(UUIDBase, StrSchema): - def __new__(cls, arg: typing.Union[str, uuid.UUID], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, uuid.UUID], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class DateSchema(DateBase, StrSchema): - def __new__(cls, arg: typing.Union[str, date], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, date], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class DateTimeSchema(DateTimeBase, StrSchema): - def __new__(cls, arg: typing.Union[str, datetime], **kwargs: Configuration): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: typing.Union[str, datetime], **kwargs: Configuration): + return super().__new__(cls, _arg, **kwargs) class DecimalSchema(DecimalBase, StrSchema): - def __new__(cls, arg: typing.Union[str], **kwargs: Configuration): + def __new__(cls, _arg: str, **kwargs: Configuration): \\"\\"\\" Note: Decimals may not be passed in because cast_to_allowed_types is only invoked once for payloads which can be simple (str) or complex (dicts or lists with nested values) @@ -23245,23 +35089,23 @@ class DecimalSchema(DecimalBase, StrSchema): if one was using it for a StrSchema (where it should be cast to str) or one is using it for NumberSchema where it should stay as Decimal. \\"\\"\\" - return super().__new__(cls, arg, **kwargs) + return super().__new__(cls, _arg, **kwargs) class BytesSchema( - SchemaTypeCheckerClsFactory(typing.Union[bytes]), Schema, + BytesMixin ): \\"\\"\\" this class will subclass bytes and is immutable \\"\\"\\" - def __new__(cls, arg: typing.Union[bytes], **kwargs: Configuration): - return super(Schema, cls).__new__(cls, arg) + def __new__(cls, _arg: bytes, **kwargs: Configuration): + return super(Schema, cls).__new__(cls, _arg) class FileSchema( - SchemaTypeCheckerClsFactory(typing.Union[FileIO]), Schema, + FileMixin ): \\"\\"\\" This class is NOT immutable @@ -23280,8 +35124,8 @@ class FileSchema( - to be able to preserve file name info \\"\\"\\" - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: Configuration): - return super(Schema, cls).__new__(cls, arg) + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader], **kwargs: Configuration): + return super(Schema, cls).__new__(cls, _arg) class BinaryBase: @@ -23289,24 +35133,24 @@ class BinaryBase: class BinarySchema( - SchemaTypeCheckerClsFactory(typing.Union[bytes, FileIO]), ComposedBase, BinaryBase, Schema, BinaryMixin ): class MetaOapg: - one_of = [ - BytesSchema, - FileSchema, - ] + @staticmethod + def one_of(): + return [ + BytesSchema, + FileSchema, + ] - def __new__(cls, arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: Configuration): - return super().__new__(cls, arg) + def __new__(cls, _arg: typing.Union[io.FileIO, io.BufferedReader, bytes], **kwargs: Configuration): + return super().__new__(cls, _arg) class BoolSchema( - SchemaTypeCheckerClsFactory(typing.Union[BoolClass]), BoolBase, Schema, BoolMixin @@ -23316,14 +35160,11 @@ class BoolSchema( def from_openapi_data_oapg(cls, arg: bool, _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, arg: bool, **kwargs: ValidationMetadata): - return super().__new__(cls, arg, **kwargs) + def __new__(cls, _arg: bool, **kwargs: ValidationMetadata): + return super().__new__(cls, _arg, **kwargs) class AnyTypeSchema( - SchemaTypeCheckerClsFactory( - typing.Union[frozendict.frozendict, tuple, decimal.Decimal, str, BoolClass, NoneClass, bytes, FileIO] - ), DictBase, ListBase, NumberBase, @@ -23331,7 +35172,7 @@ class AnyTypeSchema( BoolBase, NoneBase, Schema, - NoneFrozenDictTupleStrDecimalBoolMixin + NoneFrozenDictTupleStrDecimalBoolFileBytesMixin ): # Python representation of a schema defined as true or {} pass @@ -23356,18 +35197,17 @@ class NotAnyTypeSchema( def __new__( cls, - *args, + *_args, _configuration: typing.Optional[Configuration] = None, ) -> 'NotAnyTypeSchema': return super().__new__( cls, - *args, + *_args, _configuration=_configuration, ) class DictSchema( - SchemaTypeCheckerClsFactory(typing.Union[frozendict.frozendict]), DictBase, Schema, FrozenDictMixin @@ -23376,14 +35216,14 @@ class DictSchema( def from_openapi_data_oapg(cls, arg: typing.Dict[str, typing.Any], _configuration: typing.Optional[Configuration] = None): return super().from_openapi_data_oapg(arg, _configuration=_configuration) - def __new__(cls, *args: typing.Union[dict, frozendict.frozendict], **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): - return super().__new__(cls, *args, **kwargs) + def __new__(cls, *_args: typing.Union[dict, frozendict.frozendict], **kwargs: typing.Union[dict, frozendict.frozendict, list, tuple, decimal.Decimal, float, int, str, date, datetime, bool, None, bytes, Schema, Unset, ValidationMetadata]): + return super().__new__(cls, *_args, **kwargs) schema_type_classes = {NoneSchema, DictSchema, ListSchema, NumberSchema, StrSchema, BoolSchema, AnyTypeSchema} -@functools.cache +@functools.lru_cache() def get_new_class( class_name: str, bases: typing.Tuple[typing.Type[typing.Union[Schema, typing.Any]], ...] @@ -23400,8 +35240,7 @@ LOG_CACHE_USAGE = False def log_cache_usage(cache_fn): if LOG_CACHE_USAGE: - print(cache_fn.__name__, cache_fn.cache_info()) -", + print(cache_fn.__name__, cache_fn.cache_info())", "test/test_models/__init__.py": "", "test/test_paths/__init__.py": "import json import typing @@ -23446,7 +35285,7 @@ class ApiTestMixin: ) @staticmethod - def headers_for_content_type(content_type: str) -> dict[str, str]: + def headers_for_content_type(content_type: str) -> typing.Dict[str, str]: return {'content-type': content_type} @classmethod @@ -23455,7 +35294,7 @@ class ApiTestMixin: body: typing.Union[str, bytes], status: int = 200, content_type: str = json_content_type, - headers: typing.Optional[dict[str, str]] = None, + headers: typing.Optional[typing.Dict[str, str]] = None, preload_content: bool = True ) -> urllib3.HTTPResponse: if headers is None: @@ -23654,9 +35493,10 @@ def test_hello(name, expected): assert hello(name) == expected ", "tox.ini": "[tox] -envlist = py39 +envlist = py37 [testenv] +passenv = PYTHON_VERSION deps=-r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt diff --git a/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-typescript-client-source-code.test.ts.snap b/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-typescript-client-source-code.test.ts.snap index 810f0c1c9..da32e71aa 100644 --- a/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-typescript-client-source-code.test.ts.snap +++ b/packages/open-api-gateway/test/project/codegen/components/__snapshots__/generated-typescript-client-source-code.test.ts.snap @@ -593,7 +593,7 @@ src/runtime.ts tsconfig.esm.json tsconfig.json ", - ".openapi-generator/VERSION": "6.0.0", + ".openapi-generator/VERSION": "6.3.0", ".projen/deps.json": Object { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", "dependencies": Array [ @@ -1227,14 +1227,16 @@ npm install PATH_TO_GENERATED_PACKAGE --save import * as runtime from '../runtime'; +import type { + ApiError, + TestRequest, + TestResponse, +} from '../models'; import { - ApiError, ApiErrorFromJSON, ApiErrorToJSON, - TestRequest, TestRequestFromJSON, TestRequestToJSON, - TestResponse, TestResponseFromJSON, TestResponseToJSON, } from '../models'; @@ -1251,7 +1253,7 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async someTestOperationRaw(requestParameters: SomeTestOperationRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async someTestOperationRaw(requestParameters: SomeTestOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.pathParam === null || requestParameters.pathParam === undefined) { throw new runtime.RequiredError('pathParam','Required parameter requestParameters.pathParam was null or undefined when calling someTestOperation.'); } @@ -1279,7 +1281,7 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async someTestOperation(requestParameters: SomeTestOperationRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async someTestOperation(requestParameters: SomeTestOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.someTestOperationRaw(requestParameters, initOverrides); return await response.value(); } @@ -1604,6 +1606,16 @@ export interface ApiError { } +/** + * Check if a given object implements the ApiError interface. + */ +export function instanceOfApiError(value: object): boolean { + let isInstance = true; + isInstance = isInstance && \\"errorMessage\\" in value; + + return isInstance; +} + export function ApiErrorFromJSON(json: any): ApiError { return ApiErrorFromJSONTyped(json, false); } @@ -1662,38 +1674,2429 @@ export interface TestRequest { } +/** + * Check if a given object implements the TestRequest interface. + */ +export function instanceOfTestRequest(value: object): boolean { + let isInstance = true; + + return isInstance; +} + export function TestRequestFromJSON(json: any): TestRequest { return TestRequestFromJSONTyped(json, false); } -export function TestRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestRequest { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'myInput': !exists(json, 'myInput') ? undefined : json['myInput'], - }; -} +export function TestRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestRequest { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'myInput': !exists(json, 'myInput') ? undefined : json['myInput'], + }; +} + +export function TestRequestToJSON(value?: TestRequest | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'myInput': value.myInput, + }; +} + +", + "src/models/TestResponse.ts": "/* tslint:disable */ +/* eslint-disable */ +/** + * Example API + * 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. + */ + +import { exists, mapValues } from '../runtime'; +import type { TestResponseMessagesInner } from './TestResponseMessagesInner'; +import { + TestResponseMessagesInnerFromJSON, + TestResponseMessagesInnerFromJSONTyped, + TestResponseMessagesInnerToJSON, +} from './TestResponseMessagesInner'; + +/** + * + * @export + * @interface TestResponse + */ +export interface TestResponse { + /** + * + * @type {Array} + * @memberof TestResponse + */ + messages: Array; +} + + +/** + * Check if a given object implements the TestResponse interface. + */ +export function instanceOfTestResponse(value: object): boolean { + let isInstance = true; + isInstance = isInstance && \\"messages\\" in value; + + return isInstance; +} + +export function TestResponseFromJSON(json: any): TestResponse { + return TestResponseFromJSONTyped(json, false); +} + +export function TestResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'messages': ((json['messages'] as Array).map(TestResponseMessagesInnerFromJSON)), + }; +} + +export function TestResponseToJSON(value?: TestResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'messages': ((value.messages as Array).map(TestResponseMessagesInnerToJSON)), + }; +} + +", + "src/models/TestResponseMessagesInner.ts": "/* tslint:disable */ +/* eslint-disable */ +/** + * Example API + * 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. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface TestResponseMessagesInner + */ +export interface TestResponseMessagesInner { + /** + * + * @type {string} + * @memberof TestResponseMessagesInner + */ + message?: string; + /** + * + * @type {number} + * @memberof TestResponseMessagesInner + */ + id: number; +} + + +/** + * Check if a given object implements the TestResponseMessagesInner interface. + */ +export function instanceOfTestResponseMessagesInner(value: object): boolean { + let isInstance = true; + isInstance = isInstance && \\"id\\" in value; + + return isInstance; +} + +export function TestResponseMessagesInnerFromJSON(json: any): TestResponseMessagesInner { + return TestResponseMessagesInnerFromJSONTyped(json, false); +} + +export function TestResponseMessagesInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestResponseMessagesInner { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'message': !exists(json, 'message') ? undefined : json['message'], + 'id': json['id'], + }; +} + +export function TestResponseMessagesInnerToJSON(value?: TestResponseMessagesInner | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'message': value.message, + 'id': value.id, + }; +} + +", + "src/models/index.ts": "/* tslint:disable */ +/* eslint-disable */ +export * from './ApiError'; +export * from './TestRequest'; +export * from './TestResponse'; +export * from './TestResponseMessagesInner'; +", + "src/runtime.ts": "/* tslint:disable */ +/* eslint-disable */ +/** + * Example API + * 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. + */ + + +export const BASE_PATH = \\"http://localhost\\".replace(/\\\\/+$/, \\"\\"); + +export interface ConfigurationParameters { + basePath?: string; // override base path + fetchApi?: FetchAPI; // override for fetch implementation + middleware?: Middleware[]; // middleware to apply before/after fetch requests + queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings + username?: string; // parameter for basic security + password?: string; // parameter for basic security + apiKey?: string | ((name: string) => string); // parameter for apiKey security + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security + headers?: HTTPHeaders; //header params we want to use on every request + credentials?: RequestCredentials; //value for the credentials param we want to use on each request +} + +export class Configuration { + constructor(private configuration: ConfigurationParameters = {}) {} + + set config(configuration: Configuration) { + this.configuration = configuration; + } + + get basePath(): string { + return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH; + } + + get fetchApi(): FetchAPI | undefined { + return this.configuration.fetchApi; + } + + get middleware(): Middleware[] { + return this.configuration.middleware || []; + } + + get queryParamsStringify(): (params: HTTPQuery) => string { + return this.configuration.queryParamsStringify || querystring; + } + + get username(): string | undefined { + return this.configuration.username; + } + + get password(): string | undefined { + return this.configuration.password; + } + + get apiKey(): ((name: string) => string) | undefined { + const apiKey = this.configuration.apiKey; + if (apiKey) { + return typeof apiKey === 'function' ? apiKey : () => apiKey; + } + return undefined; + } + + get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { + const accessToken = this.configuration.accessToken; + if (accessToken) { + return typeof accessToken === 'function' ? accessToken : async () => accessToken; + } + return undefined; + } + + get headers(): HTTPHeaders | undefined { + return this.configuration.headers; + } + + get credentials(): RequestCredentials | undefined { + return this.configuration.credentials; + } +} + +export const DefaultConfig = new Configuration(); + +/** + * This is the base class for all generated API classes. + */ +export class BaseAPI { + + private middleware: Middleware[]; + + constructor(protected configuration = DefaultConfig) { + this.middleware = configuration.middleware; + } + + withMiddleware(this: T, ...middlewares: Middleware[]) { + const next = this.clone(); + next.middleware = next.middleware.concat(...middlewares); + return next; + } + + withPreMiddleware(this: T, ...preMiddlewares: Array) { + const middlewares = preMiddlewares.map((pre) => ({ pre })); + return this.withMiddleware(...middlewares); + } + + withPostMiddleware(this: T, ...postMiddlewares: Array) { + const middlewares = postMiddlewares.map((post) => ({ post })); + return this.withMiddleware(...middlewares); + } + + protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise { + const { url, init } = await this.createFetchParams(context, initOverrides); + const response = await this.fetchApi(url, init); + if (response && (response.status >= 200 && response.status < 300)) { + return response; + } + throw new ResponseError(response, 'Response returned an error code'); + } + + private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) { + let url = this.configuration.basePath + context.path; + if (context.query !== undefined && Object.keys(context.query).length !== 0) { + // only add the querystring to the URL if there are query parameters. + // this is done to avoid urls ending with a \\"?\\" character which buggy webservers + // do not handle correctly sometimes. + url += '?' + this.configuration.queryParamsStringify(context.query); + } + + const headers = Object.assign({}, this.configuration.headers, context.headers); + Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {}); + + const initOverrideFn = + typeof initOverrides === \\"function\\" + ? initOverrides + : async () => initOverrides; + + const initParams = { + method: context.method, + headers, + body: context.body, + credentials: this.configuration.credentials, + }; + + const overriddenInit: RequestInit = { + ...initParams, + ...(await initOverrideFn({ + init: initParams, + context, + })) + }; + + const init: RequestInit = { + ...overriddenInit, + body: + isFormData(overriddenInit.body) || + overriddenInit.body instanceof URLSearchParams || + isBlob(overriddenInit.body) + ? overriddenInit.body + : JSON.stringify(overriddenInit.body), + }; + + return { url, init }; + } + + private fetchApi = async (url: string, init: RequestInit) => { + let fetchParams = { url, init }; + for (const middleware of this.middleware) { + if (middleware.pre) { + fetchParams = await middleware.pre({ + fetch: this.fetchApi, + ...fetchParams, + }) || fetchParams; + } + } + let response: Response | undefined = undefined; + try { + response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + } catch (e) { + for (const middleware of this.middleware) { + if (middleware.onError) { + response = await middleware.onError({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + error: e, + response: response ? response.clone() : undefined, + }) || response; + } + } + if (response === undefined) { + if (e instanceof Error) { + throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); + } else { + throw e; + } + } + } + for (const middleware of this.middleware) { + if (middleware.post) { + response = await middleware.post({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + response: response.clone(), + }) || response; + } + } + return response; + } + + /** + * Create a shallow clone of \`this\` by constructing a new instance + * and then shallow cloning data members. + */ + private clone(this: T): T { + const constructor = this.constructor as any; + const next = new constructor(this.configuration); + next.middleware = this.middleware.slice(); + return next; + } +}; + +function isBlob(value: any): value is Blob { + return typeof Blob !== 'undefined' && value instanceof Blob; +} + +function isFormData(value: any): value is FormData { + return typeof FormData !== \\"undefined\\" && value instanceof FormData; +} + +export class ResponseError extends Error { + override name: \\"ResponseError\\" = \\"ResponseError\\"; + constructor(public response: Response, msg?: string) { + super(msg); + } +} + +export class FetchError extends Error { + override name: \\"FetchError\\" = \\"FetchError\\"; + constructor(public cause: Error, msg?: string) { + super(msg); + } +} + +export class RequiredError extends Error { + override name: \\"RequiredError\\" = \\"RequiredError\\"; + constructor(public field: string, msg?: string) { + super(msg); + } +} + +export const COLLECTION_FORMATS = { + csv: \\",\\", + ssv: \\" \\", + tsv: \\"\\\\t\\", + pipes: \\"|\\", +}; + +export type FetchAPI = WindowOrWorkerGlobalScope['fetch']; + +export type Json = any; +export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD'; +export type HTTPHeaders = { [key: string]: string }; +export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery }; +export type HTTPBody = Json | FormData | URLSearchParams; +export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }; +export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; + +export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise + +export interface FetchParams { + url: string; + init: RequestInit; +} + +export interface RequestOpts { + path: string; + method: HTTPMethod; + headers: HTTPHeaders; + query?: HTTPQuery; + body?: HTTPBody; +} + +export function exists(json: any, key: string) { + const value = json[key]; + return value !== null && value !== undefined; +} + +export function querystring(params: HTTPQuery, prefix: string = ''): string { + return Object.keys(params) + .map(key => querystringSingleKey(key, params[key], prefix)) + .filter(part => part.length > 0) + .join('&'); +} + +function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { + const fullKey = keyPrefix + (keyPrefix.length ? \`[\${key}]\` : key); + if (value instanceof Array) { + const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) + .join(\`&\${encodeURIComponent(fullKey)}=\`); + return \`\${encodeURIComponent(fullKey)}=\${multiValue}\`; + } + if (value instanceof Set) { + const valueAsArray = Array.from(value); + return querystringSingleKey(key, valueAsArray, keyPrefix); + } + if (value instanceof Date) { + return \`\${encodeURIComponent(fullKey)}=\${encodeURIComponent(value.toISOString())}\`; + } + if (value instanceof Object) { + return querystring(value as HTTPQuery, fullKey); + } + return \`\${encodeURIComponent(fullKey)}=\${encodeURIComponent(String(value))}\`; +} + +export function mapValues(data: any, fn: (item: any) => any) { + return Object.keys(data).reduce( + (acc, key) => ({ ...acc, [key]: fn(data[key]) }), + {} + ); +} + +export function canConsumeForm(consumes: Consume[]): boolean { + for (const consume of consumes) { + if ('multipart/form-data' === consume.contentType) { + return true; + } + } + return false; +} + +export interface Consume { + contentType: string; +} + +export interface RequestContext { + fetch: FetchAPI; + url: string; + init: RequestInit; +} + +export interface ResponseContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + response: Response; +} + +export interface ErrorContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + error: unknown; + response?: Response; +} + +export interface Middleware { + pre?(context: RequestContext): Promise; + post?(context: ResponseContext): Promise; + onError?(context: ErrorContext): Promise; +} + +export interface ApiResponse { + raw: Response; + value(): Promise; +} + +export interface ResponseTransformer { + (json: any): T; +} + +export class JSONApiResponse { + constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {} + + async value(): Promise { + return this.transformer(await this.raw.json()); + } +} + +export class VoidApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return undefined; + } +} + +export class BlobApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return await this.raw.blob(); + }; +} + +export class TextApiResponse { + constructor(public raw: Response) {} + + async value(): Promise { + return await this.raw.text(); + }; +} +", + "test/hello.test.ts": "import { Hello } from '../src'; + +test('hello', () => { + expect(new Hello().sayHello()).toBe('hello, world!'); +});", + "tsconfig.dev.json": Object { + "compilerOptions": Object { + "alwaysStrict": true, + "declaration": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "inlineSourceMap": true, + "inlineSources": true, + "lib": Array [ + "es2019", + ], + "module": "CommonJS", + "noEmitOnError": false, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "resolveJsonModule": true, + "strict": true, + "strictNullChecks": true, + "strictPropertyInitialization": true, + "stripInternal": true, + "target": "ES2019", + }, + "exclude": Array [ + "node_modules", + ], + "include": Array [ + ".projenrc.js", + "src/**/*.ts", + "test/**/*.ts", + ], + }, + "tsconfig.esm.json": Object { + "compilerOptions": Object { + "module": "esnext", + "outDir": "dist/esm", + }, + "extends": "./tsconfig.json", + }, + "tsconfig.json": Object { + "compilerOptions": Object { + "declaration": true, + "module": "commonjs", + "moduleResolution": "node", + "outDir": "dist", + "target": "es6", + "typeRoots": Array [ + "node_modules/@types", + ], + }, + "exclude": Array [ + "dist", + "node_modules", + ], + }, +} +`; + +exports[`Generated Typescript Client Code Unit Tests Multiple Tags 1`] = ` +Object { + ".eslintrc.json": Object { + "env": Object { + "jest": true, + "node": true, + }, + "extends": Array [ + "plugin:import/typescript", + ], + "ignorePatterns": Array [ + "*.js", + "!.projenrc.js", + "*.d.ts", + "node_modules/", + "*.generated.ts", + "coverage", + ], + "overrides": Array [ + Object { + "files": Array [ + ".projenrc.js", + ], + "rules": Object { + "@typescript-eslint/no-require-imports": "off", + "import/no-extraneous-dependencies": "off", + }, + }, + ], + "parser": "@typescript-eslint/parser", + "parserOptions": Object { + "ecmaVersion": 2018, + "project": "./tsconfig.dev.json", + "sourceType": "module", + }, + "plugins": Array [ + "@typescript-eslint", + "import", + ], + "root": true, + "rules": Object { + "@typescript-eslint/indent": Array [ + "error", + 2, + ], + "@typescript-eslint/member-delimiter-style": Array [ + "error", + ], + "@typescript-eslint/member-ordering": Array [ + "error", + Object { + "default": Array [ + "public-static-field", + "public-static-method", + "protected-static-field", + "protected-static-method", + "private-static-field", + "private-static-method", + "field", + "constructor", + "method", + ], + }, + ], + "@typescript-eslint/no-floating-promises": Array [ + "error", + ], + "@typescript-eslint/no-require-imports": Array [ + "error", + ], + "@typescript-eslint/no-shadow": Array [ + "error", + ], + "@typescript-eslint/return-await": Array [ + "error", + ], + "array-bracket-newline": Array [ + "error", + "consistent", + ], + "array-bracket-spacing": Array [ + "error", + "never", + ], + "brace-style": Array [ + "error", + "1tbs", + Object { + "allowSingleLine": true, + }, + ], + "comma-dangle": Array [ + "error", + "always-multiline", + ], + "comma-spacing": Array [ + "error", + Object { + "after": true, + "before": false, + }, + ], + "curly": Array [ + "error", + "multi-line", + "consistent", + ], + "dot-notation": Array [ + "error", + ], + "import/no-extraneous-dependencies": Array [ + "error", + Object { + "devDependencies": Array [ + "**/test/**", + "**/build-tools/**", + ], + "optionalDependencies": false, + "peerDependencies": true, + }, + ], + "import/no-unresolved": Array [ + "error", + ], + "import/order": Array [ + "warn", + Object { + "alphabetize": Object { + "caseInsensitive": true, + "order": "asc", + }, + "groups": Array [ + "builtin", + "external", + ], + }, + ], + "indent": Array [ + "off", + ], + "key-spacing": Array [ + "error", + ], + "keyword-spacing": Array [ + "error", + ], + "max-len": Array [ + "error", + Object { + "code": 150, + "ignoreComments": true, + "ignoreRegExpLiterals": true, + "ignoreStrings": true, + "ignoreTemplateLiterals": true, + "ignoreUrls": true, + }, + ], + "no-bitwise": Array [ + "error", + ], + "no-duplicate-imports": Array [ + "error", + ], + "no-multi-spaces": Array [ + "error", + Object { + "ignoreEOLComments": false, + }, + ], + "no-multiple-empty-lines": Array [ + "error", + ], + "no-return-await": Array [ + "off", + ], + "no-shadow": Array [ + "off", + ], + "no-trailing-spaces": Array [ + "error", + ], + "object-curly-newline": Array [ + "error", + Object { + "consistent": true, + "multiline": true, + }, + ], + "object-curly-spacing": Array [ + "error", + "always", + ], + "object-property-newline": Array [ + "error", + Object { + "allowAllPropertiesOnSameLine": true, + }, + ], + "quote-props": Array [ + "error", + "consistent-as-needed", + ], + "quotes": Array [ + "error", + "single", + Object { + "avoidEscape": true, + }, + ], + "semi": Array [ + "error", + "always", + ], + "space-before-blocks": Array [ + "error", + ], + }, + "settings": Object { + "import/parsers": Object { + "@typescript-eslint/parser": Array [ + ".ts", + ".tsx", + ], + }, + "import/resolver": Object { + "node": Object {}, + "typescript": Object { + "alwaysTryTypes": true, + "project": "./tsconfig.dev.json", + }, + }, + }, + }, + ".gitattributes": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +*.snap linguist-generated +/.eslintrc.json linguist-generated +/.gitattributes linguist-generated +/.github/pull_request_template.md linguist-generated +/.github/workflows/build.yml linguist-generated +/.github/workflows/pull-request-lint.yml linguist-generated +/.github/workflows/release.yml linguist-generated +/.github/workflows/upgrade-main.yml linguist-generated +/.gitignore linguist-generated +/.mergify.yml linguist-generated +/.npmignore linguist-generated +/.projen/** linguist-generated +/.projen/deps.json linguist-generated +/.projen/files.json linguist-generated +/.projen/tasks.json linguist-generated +/LICENSE linguist-generated +/package.json linguist-generated +/tsconfig.dev.json linguist-generated +/tsconfig.json linguist-generated +/yarn.lock linguist-generated", + ".github/pull_request_template.md": "Fixes #", + ".github/workflows/build.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +name: build +on: + pull_request: {} + workflow_dispatch: {} +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + self_mutation_happened: \${{ steps.self_mutation.outputs.self_mutation_happened }} + env: + CI: \\"true\\" + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: \${{ github.event.pull_request.head.ref }} + repository: \${{ github.event.pull_request.head.repo.full_name }} + - name: Install dependencies + run: yarn install --check-files + - name: build + run: npx projen build + - name: Find mutations + id: self_mutation + run: |- + git add . + git diff --staged --patch --exit-code > .repo.patch || echo \\"self_mutation_happened=true\\" >> $GITHUB_OUTPUT + - name: Upload patch + if: steps.self_mutation.outputs.self_mutation_happened + uses: actions/upload-artifact@v3 + with: + name: .repo.patch + path: .repo.patch + - name: Fail build on mutation + if: steps.self_mutation.outputs.self_mutation_happened + run: |- + echo \\"::error::Files were changed during build (see build log). If this was triggered from a fork, you will need to update your branch.\\" + cat .repo.patch + exit 1 + self-mutation: + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + if: always() && needs.build.outputs.self_mutation_happened && !(github.event.pull_request.head.repo.full_name != github.repository) + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: \${{ secrets.PROJEN_GITHUB_TOKEN }} + ref: \${{ github.event.pull_request.head.ref }} + repository: \${{ github.event.pull_request.head.repo.full_name }} + - name: Download patch + uses: actions/download-artifact@v3 + with: + name: .repo.patch + path: \${{ runner.temp }} + - name: Apply patch + run: '[ -s \${{ runner.temp }}/.repo.patch ] && git apply \${{ runner.temp }}/.repo.patch || echo \\"Empty patch. Skipping.\\"' + - name: Set git identity + run: |- + git config user.name \\"github-actions\\" + git config user.email \\"github-actions@github.com\\" + - name: Push changes + run: |2- + git add . + git commit -s -m \\"chore: self mutation\\" + git push origin HEAD:\${{ github.event.pull_request.head.ref }} +", + ".github/workflows/pull-request-lint.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +name: pull-request-lint +on: + pull_request_target: + types: + - labeled + - opened + - synchronize + - reopened + - ready_for_review + - edited +jobs: + validate: + name: Validate PR title + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: amannn/action-semantic-pull-request@v5.0.2 + env: + GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + with: + types: |- + feat + fix + chore + requireScope: false +", + ".github/workflows/release.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +name: release +on: + push: + branches: + - main + workflow_dispatch: {} +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + outputs: + latest_commit: \${{ steps.git_remote.outputs.latest_commit }} + env: + CI: \\"true\\" + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set git identity + run: |- + git config user.name \\"github-actions\\" + git config user.email \\"github-actions@github.com\\" + - name: Install dependencies + run: yarn install --check-files --frozen-lockfile + - name: release + run: npx projen release + - name: Check for new commits + id: git_remote + run: echo \\"latest_commit=$(git ls-remote origin -h \${{ github.ref }} | cut -f1)\\" >> $GITHUB_OUTPUT + - name: Backup artifact permissions + if: \${{ steps.git_remote.outputs.latest_commit == github.sha }} + run: cd dist && getfacl -R . > permissions-backup.acl + continue-on-error: true + - name: Upload artifact + if: \${{ steps.git_remote.outputs.latest_commit == github.sha }} + uses: actions/upload-artifact@v3 + with: + name: build-artifact + path: dist + release_github: + name: Publish to GitHub Releases + needs: release + runs-on: ubuntu-latest + permissions: + contents: write + if: needs.release.outputs.latest_commit == github.sha + steps: + - uses: actions/setup-node@v3 + with: + node-version: 14.x + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifact + path: dist + - name: Restore build artifact permissions + run: cd dist && setfacl --restore=permissions-backup.acl + continue-on-error: true + - name: Release + env: + GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: \${{ github.repository }} + GITHUB_REF: \${{ github.ref }} + run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R $GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt) --target $GITHUB_REF 2> $errout && true; exitcode=$?; if [ $exitcode -ne 0 ] && ! grep -q \\"Release.tag_name already exists\\" $errout; then cat $errout; exit $exitcode; fi +", + ".github/workflows/upgrade-main.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +name: upgrade-main +on: + workflow_dispatch: {} + schedule: + - cron: 0 0 * * * +jobs: + upgrade: + name: Upgrade + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + patch_created: \${{ steps.create_patch.outputs.patch_created }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: main + - name: Install dependencies + run: yarn install --check-files --frozen-lockfile + - name: Upgrade dependencies + run: npx projen upgrade + - name: Find mutations + id: create_patch + run: |- + git add . + git diff --staged --patch --exit-code > .repo.patch || echo \\"patch_created=true\\" >> $GITHUB_OUTPUT + - name: Upload patch + if: steps.create_patch.outputs.patch_created + uses: actions/upload-artifact@v3 + with: + name: .repo.patch + path: .repo.patch + pr: + name: Create Pull Request + needs: upgrade + runs-on: ubuntu-latest + permissions: + contents: read + if: \${{ needs.upgrade.outputs.patch_created }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: main + - name: Download patch + uses: actions/download-artifact@v3 + with: + name: .repo.patch + path: \${{ runner.temp }} + - name: Apply patch + run: '[ -s \${{ runner.temp }}/.repo.patch ] && git apply \${{ runner.temp }}/.repo.patch || echo \\"Empty patch. Skipping.\\"' + - name: Set git identity + run: |- + git config user.name \\"github-actions\\" + git config user.email \\"github-actions@github.com\\" + - name: Create Pull Request + id: create-pr + uses: peter-evans/create-pull-request@v4 + with: + token: \${{ secrets.PROJEN_GITHUB_TOKEN }} + commit-message: |- + chore(deps): upgrade dependencies + + Upgrades project dependencies. See details in [workflow run]. + + [Workflow Run]: https://github.com/\${{ github.repository }}/actions/runs/\${{ github.run_id }} + + ------ + + *Automatically created by projen via the \\"upgrade-main\\" workflow* + branch: github-actions/upgrade-main + title: \\"chore(deps): upgrade dependencies\\" + body: |- + Upgrades project dependencies. See details in [workflow run]. + + [Workflow Run]: https://github.com/\${{ github.repository }}/actions/runs/\${{ github.run_id }} + + ------ + + *Automatically created by projen via the \\"upgrade-main\\" workflow* + author: github-actions + committer: github-actions + signoff: true +", + ".gitignore": "wwwroot/*.js +node_modules +typings +dist +", + ".mergify.yml": "# ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". + +queue_rules: + - name: default + conditions: + - \\"#approved-reviews-by>=1\\" + - -label~=(do-not-merge) + - status-success=build +pull_request_rules: + - name: Automatic merge on approval and successful build + actions: + delete_head_branch: {} + queue: + method: squash + name: default + commit_message_template: |- + {{ title }} (#{{ number }}) + + {{ body }} + conditions: + - \\"#approved-reviews-by>=1\\" + - -label~=(do-not-merge) + - status-success=build +", + ".npmignore": "README.md", + ".openapi-generator-ignore": "# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md +", + ".openapi-generator/FILES": ".gitignore +.npmignore +.openapi-generator-ignore +README.md +package.json +src/apis/DefaultApi.ts +src/apis/DefaultApi/OperationConfig.ts +src/apis/Tag1Api.ts +src/apis/Tag2Api.ts +src/apis/index.ts +src/index.ts +src/runtime.ts +tsconfig.esm.json +tsconfig.json +", + ".openapi-generator/VERSION": "6.3.0", + ".projen/deps.json": Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "dependencies": Array [ + Object { + "name": "@types/jest", + "type": "build", + }, + Object { + "name": "@types/node", + "type": "build", + "version": "^14", + }, + Object { + "name": "@typescript-eslint/eslint-plugin", + "type": "build", + "version": "^5", + }, + Object { + "name": "@typescript-eslint/parser", + "type": "build", + "version": "^5", + }, + Object { + "name": "eslint-import-resolver-node", + "type": "build", + }, + Object { + "name": "eslint-import-resolver-typescript", + "type": "build", + }, + Object { + "name": "eslint-plugin-import", + "type": "build", + }, + Object { + "name": "eslint", + "type": "build", + "version": "^8", + }, + Object { + "name": "jest", + "type": "build", + }, + Object { + "name": "jest-junit", + "type": "build", + "version": "^13", + }, + Object { + "name": "npm-check-updates", + "type": "build", + "version": "^16", + }, + Object { + "name": "projen", + "type": "build", + }, + Object { + "name": "standard-version", + "type": "build", + "version": "^9", + }, + Object { + "name": "ts-jest", + "type": "build", + }, + Object { + "name": "typescript", + "type": "build", + }, + ], + }, + ".projen/files.json": Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "files": Array [ + ".eslintrc.json", + ".gitattributes", + ".github/pull_request_template.md", + ".github/workflows/build.yml", + ".github/workflows/pull-request-lint.yml", + ".github/workflows/release.yml", + ".github/workflows/upgrade-main.yml", + ".gitignore", + ".mergify.yml", + ".npmignore", + ".projen/deps.json", + ".projen/files.json", + ".projen/tasks.json", + "LICENSE", + "tsconfig.dev.json", + "tsconfig.json", + ], + }, + ".projen/tasks.json": Object { + "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", + "env": Object { + "PATH": "$(npx -c \\"node -e \\\\\\"console.log(process.env.PATH)\\\\\\"\\")", + }, + "tasks": Object { + "build": Object { + "description": "Full release build", + "name": "build", + "steps": Array [ + Object { + "spawn": "default", + }, + Object { + "spawn": "pre-compile", + }, + Object { + "spawn": "compile", + }, + Object { + "spawn": "post-compile", + }, + Object { + "spawn": "test", + }, + Object { + "spawn": "package", + }, + ], + }, + "bump": Object { + "condition": "! git log --oneline -1 | grep -q \\"chore(release):\\"", + "description": "Bumps version based on latest git tag and generates a changelog entry", + "env": Object { + "BUMPFILE": "dist/version.txt", + "CHANGELOG": "dist/changelog.md", + "OUTFILE": "package.json", + "RELEASETAG": "dist/releasetag.txt", + "RELEASE_TAG_PREFIX": "", + }, + "name": "bump", + "steps": Array [ + Object { + "builtin": "release/bump-version", + }, + ], + }, + "clobber": Object { + "condition": "git diff --exit-code > /dev/null", + "description": "hard resets to HEAD of origin and cleans the local repo", + "env": Object { + "BRANCH": "$(git branch --show-current)", + }, + "name": "clobber", + "steps": Array [ + Object { + "exec": "git checkout -b scratch", + "name": "save current HEAD in \\"scratch\\" branch", + }, + Object { + "exec": "git checkout $BRANCH", + }, + Object { + "exec": "git fetch origin", + "name": "fetch latest changes from origin", + }, + Object { + "exec": "git reset --hard origin/$BRANCH", + "name": "hard reset to origin commit", + }, + Object { + "exec": "git clean -fdx", + "name": "clean all untracked files", + }, + Object { + "say": "ready to rock! (unpushed commits are under the \\"scratch\\" branch)", + }, + ], + }, + "compile": Object { + "description": "Only compile", + "name": "compile", + "steps": Array [ + Object { + "exec": "tsc --build", + }, + ], + }, + "default": Object { + "description": "Synthesize project files", + "name": "default", + "steps": Array [ + Object { + "exec": "node .projenrc.js", + }, + ], + }, + "eject": Object { + "description": "Remove projen from the project", + "env": Object { + "PROJEN_EJECTING": "true", + }, + "name": "eject", + "steps": Array [ + Object { + "spawn": "default", + }, + ], + }, + "eslint": Object { + "description": "Runs eslint against the codebase", + "name": "eslint", + "steps": Array [ + Object { + "exec": "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern src test build-tools .projenrc.js", + }, + ], + }, + "package": Object { + "description": "Creates the distribution package", + "name": "package", + "steps": Array [ + Object { + "exec": "mkdir -p dist/js", + }, + Object { + "exec": "mv $(npm pack) dist/js/", + }, + ], + }, + "post-compile": Object { + "description": "Runs after successful compilation", + "name": "post-compile", + }, + "post-upgrade": Object { + "description": "Runs after upgrading dependencies", + "name": "post-upgrade", + }, + "pre-compile": Object { + "description": "Prepare the project for compilation", + "name": "pre-compile", + }, + "release": Object { + "description": "Prepare a release from \\"main\\" branch", + "env": Object { + "RELEASE": "true", + }, + "name": "release", + "steps": Array [ + Object { + "exec": "rm -fr dist", + }, + Object { + "spawn": "bump", + }, + Object { + "spawn": "build", + }, + Object { + "spawn": "unbump", + }, + Object { + "exec": "git diff --ignore-space-at-eol --exit-code", + }, + ], + }, + "test": Object { + "description": "Run tests", + "name": "test", + "steps": Array [ + Object { + "exec": "jest --passWithNoTests --updateSnapshot", + "receiveArgs": true, + }, + Object { + "spawn": "eslint", + }, + ], + }, + "test:watch": Object { + "description": "Run jest in watch mode", + "name": "test:watch", + "steps": Array [ + Object { + "exec": "jest --watch", + }, + ], + }, + "unbump": Object { + "description": "Restores version to 0.0.0", + "env": Object { + "BUMPFILE": "dist/version.txt", + "CHANGELOG": "dist/changelog.md", + "OUTFILE": "package.json", + "RELEASETAG": "dist/releasetag.txt", + "RELEASE_TAG_PREFIX": "", + }, + "name": "unbump", + "steps": Array [ + Object { + "builtin": "release/reset-version", + }, + ], + }, + "upgrade": Object { + "description": "upgrade dependencies", + "env": Object { + "CI": "0", + }, + "name": "upgrade", + "steps": Array [ + Object { + "exec": "yarn upgrade npm-check-updates", + }, + Object { + "exec": "npm-check-updates --dep dev --upgrade --target=minor", + }, + Object { + "exec": "npm-check-updates --dep optional --upgrade --target=minor", + }, + Object { + "exec": "npm-check-updates --dep peer --upgrade --target=minor", + }, + Object { + "exec": "npm-check-updates --dep prod --upgrade --target=minor", + }, + Object { + "exec": "npm-check-updates --dep bundle --upgrade --target=minor", + }, + Object { + "exec": "yarn install --check-files", + }, + Object { + "exec": "yarn upgrade", + }, + Object { + "exec": "npx projen", + }, + Object { + "spawn": "post-upgrade", + }, + ], + }, + "watch": Object { + "description": "Watch & compile in the background", + "name": "watch", + "steps": Array [ + Object { + "exec": "tsc --build -w", + }, + ], + }, + }, + }, + "LICENSE": " + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + \\"License\\" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + \\"Licensor\\" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + \\"Legal Entity\\" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + \\"control\\" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + \\"You\\" (or \\"Your\\") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + \\"Source\\" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + \\"Object\\" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + \\"Work\\" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + \\"Derivative Works\\" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + \\"Contribution\\" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, \\"submitted\\" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as \\"Not a Contribution.\\" + + \\"Contributor\\" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a \\"NOTICE\\" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an \\"AS IS\\" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets \\"[]\\" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same \\"printed page\\" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the \\"License\\"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an \\"AS IS\\" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +", + "README.md": "## test@1.0.0 + +This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments: + +Environment +* Node.js +* Webpack +* Browserify + +Language level +* ES5 - you must have a Promises/A+ library installed +* ES6 + +Module system +* CommonJS +* ES6 module system + +It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via \`package.json\`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html)) + +### Building + +To build and compile the typescript sources to javascript use: +\`\`\` +npm install +npm run build +\`\`\` + +### Publishing + +First build the package then run \`\`\`npm publish\`\`\` + +### Consuming + +navigate to the folder of your consuming project and run one of the following commands. + +_published:_ + +\`\`\` +npm install test@1.0.0 --save +\`\`\` + +_unPublished (not recommended):_ + +\`\`\` +npm install PATH_TO_GENERATED_PACKAGE --save +", + "package.json": Object { + "author": "OpenAPI-Generator", + "description": "OpenAPI client for test", + "devDependencies": Object { + "typescript": "^4.0", + }, + "main": "./dist/index.js", + "module": "./dist/esm/index.js", + "name": "test", + "repository": Object { + "type": "git", + "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git", + }, + "scripts": Object { + "build": "tsc && tsc -p tsconfig.esm.json", + "prepare": "npm run build", + }, + "sideEffects": false, + "typings": "./dist/index.d.ts", + "version": "1.0.0", + }, + "src/apis/DefaultApi.ts": "/* tslint:disable */ +/* eslint-disable */ +/** + * Multiple Tags Test + * 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. + */ + + +import * as runtime from '../runtime'; + +/** + * + */ +export class DefaultApi extends runtime.BaseAPI { + + /** + */ + async neitherRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: \`/neither\`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + */ + async neither(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.neitherRaw(initOverrides); + } + +} +", + "src/apis/DefaultApi/OperationConfig.ts": "// Import models +import { +} from '../../models'; +// Import request parameter interfaces +import { + + + + +} from '..'; + +// API Gateway Types +import { APIGatewayProxyEvent, APIGatewayProxyResult, Context } from \\"aws-lambda\\"; + +// Generic type for object keyed by operation names +export interface OperationConfig { + neither: T; + both: T; + tag1: T; + tag2: T; +} + +// Look up path and http method for a given operation name +export const OperationLookup = { + neither: { + path: '/neither', + method: 'GET', + }, + both: { + path: '/both', + method: 'GET', + }, + tag1: { + path: '/tag1', + method: 'GET', + }, + tag2: { + path: '/tag2', + method: 'GET', + }, +}; + +export class Operations { + /** + * Return an OperationConfig with the same value for every operation + */ + public static all = (value: T): OperationConfig => Object.fromEntries( + Object.keys(OperationLookup).map((operationId) => [operationId, value]) + ) as unknown as OperationConfig; +} + +// Standard apigateway request parameters (query parameters or path parameters, multi or single value) +type ApiGatewayRequestParameters = { [key: string]: string | string[] | undefined }; + +/** + * URI decode for a string or array of strings + */ +const uriDecode = (value: string | string[]): string | string[] => + typeof value === 'string' ? decodeURIComponent(value) : value.map((v) => decodeURIComponent(v)); + +/** + * URI decodes apigateway request parameters (query or path parameters) + */ +const decodeRequestParameters = (parameters: ApiGatewayRequestParameters): ApiGatewayRequestParameters => { + const decodedParameters = {}; + Object.keys(parameters || {}).forEach((key) => { + decodedParameters[key] = parameters[key] ? uriDecode(parameters[key]) : parameters[key]; + }); + return decodedParameters; +}; + +/** + * Parse the body if the content type is json, otherwise leave as a raw string + */ +const parseBody = (body: string, demarshal: (body: string) => any, contentTypes: string[]): any => contentTypes.filter((contentType) => contentType !== 'application/json').length === 0 ? demarshal(body || '{}') : body; + +type OperationIds = | 'neither' | 'both' | 'tag1' | 'tag2'; +type OperationApiGatewayProxyResult = APIGatewayProxyResult & { __operationId?: T }; + +// Api gateway lambda handler type +type OperationApiGatewayLambdaHandler = (event: APIGatewayProxyEvent, context: Context) => Promise>; + +// Type of the response to be returned by an operation lambda handler +export interface OperationResponse { + statusCode: StatusCode; + headers?: { [key: string]: string }; + body: Body; +} + +// Input for a lambda handler for an operation +export type LambdaRequestParameters = { + requestParameters: RequestParameters, + requestArrayParameters: RequestArrayParameters, + body: RequestBody, +}; + +export type InterceptorContext = { [key: string]: any }; + +export interface RequestInput { + input: LambdaRequestParameters; + event: APIGatewayProxyEvent; + context: Context; + interceptorContext: InterceptorContext; +} + +export interface ChainedRequestInput extends RequestInput { + chain: LambdaHandlerChain; +} + +/** + * A lambda handler function which is part of a chain. It may invoke the remainder of the chain via the given chain input + */ +export type ChainedLambdaHandlerFunction = ( + input: ChainedRequestInput, +) => Promise; + +// Type for a lambda handler function to be wrapped +export type LambdaHandlerFunction = ( + input: RequestInput, +) => Promise; + +export interface LambdaHandlerChain { + next: LambdaHandlerFunction; +} + +// Interceptor is a type alias for ChainedLambdaHandlerFunction +export type Interceptor = ChainedLambdaHandlerFunction; + +/** + * Build a chain from the given array of chained lambda handlers + */ +const buildHandlerChain = ( + ...handlers: ChainedLambdaHandlerFunction[] +): LambdaHandlerChain => { + if (handlers.length === 0) { + return { + next: () => { + throw new Error(\\"No more handlers remain in the chain! The last handler should not call next.\\"); + } + }; + } + const [currentHandler, ...remainingHandlers] = handlers; + return { + next: (input) => { + return currentHandler({ + ...input, + chain: buildHandlerChain(...remainingHandlers), + }); + }, + }; +}; + +/** + * Single-value path/query parameters for Neither + */ +export interface NeitherRequestParameters { +} + +/** + * Multi-value query parameters for Neither + */ +export interface NeitherRequestArrayParameters { +} + +/** + * Request body parameter for Neither + */ +export type NeitherRequestBody = never; + +export type Neither200OperationResponse = OperationResponse<200, undefined>; +export type NeitherOperationResponses = | Neither200OperationResponse ; + +// Type that the handler function provided to the wrapper must conform to +export type NeitherHandlerFunction = LambdaHandlerFunction; +export type NeitherChainedHandlerFunction = ChainedLambdaHandlerFunction; + +/** + * Lambda handler wrapper to provide typed interface for the implementation of neither + */ +export const neitherHandler = ( + firstHandler: NeitherChainedHandlerFunction, + ...remainingHandlers: NeitherChainedHandlerFunction[] +): OperationApiGatewayLambdaHandler<'neither'> => async (event: any, context: any, _callback?: any, additionalInterceptors: NeitherChainedHandlerFunction[] = []): Promise => { + const requestParameters = decodeRequestParameters({ + ...(event.pathParameters || {}), + ...(event.queryStringParameters || {}), + }) as unknown as NeitherRequestParameters; + + const requestArrayParameters = decodeRequestParameters({ + ...(event.multiValueQueryStringParameters || {}), + }) as unknown as NeitherRequestArrayParameters; + + const demarshal = (bodyString: string): any => { + return {}; + }; + const body = parseBody(event.body, demarshal, ['application/json']) as NeitherRequestBody; + + const chain = buildHandlerChain(...additionalInterceptors, firstHandler, ...remainingHandlers); + const response = await chain.next({ + input: { + requestParameters, + requestArrayParameters, + body, + }, + event, + context, + interceptorContext: {}, + }); + + const marshal = (statusCode: number, responseBody: any): string => { + let marshalledBody = responseBody; + switch(statusCode) { + case 200: + break; + default: + break; + } + + return marshalledBody; + }; + + return { + ...response, + body: response.body ? marshal(response.statusCode, response.body) : '', + }; +}; +/** + * Single-value path/query parameters for Both + */ +export interface BothRequestParameters { +} + +/** + * Multi-value query parameters for Both + */ +export interface BothRequestArrayParameters { +} + +/** + * Request body parameter for Both + */ +export type BothRequestBody = never; + +export type Both200OperationResponse = OperationResponse<200, undefined>; +export type BothOperationResponses = | Both200OperationResponse ; + +// Type that the handler function provided to the wrapper must conform to +export type BothHandlerFunction = LambdaHandlerFunction; +export type BothChainedHandlerFunction = ChainedLambdaHandlerFunction; + +/** + * Lambda handler wrapper to provide typed interface for the implementation of both + */ +export const bothHandler = ( + firstHandler: BothChainedHandlerFunction, + ...remainingHandlers: BothChainedHandlerFunction[] +): OperationApiGatewayLambdaHandler<'both'> => async (event: any, context: any, _callback?: any, additionalInterceptors: BothChainedHandlerFunction[] = []): Promise => { + const requestParameters = decodeRequestParameters({ + ...(event.pathParameters || {}), + ...(event.queryStringParameters || {}), + }) as unknown as BothRequestParameters; + + const requestArrayParameters = decodeRequestParameters({ + ...(event.multiValueQueryStringParameters || {}), + }) as unknown as BothRequestArrayParameters; + + const demarshal = (bodyString: string): any => { + return {}; + }; + const body = parseBody(event.body, demarshal, ['application/json']) as BothRequestBody; + + const chain = buildHandlerChain(...additionalInterceptors, firstHandler, ...remainingHandlers); + const response = await chain.next({ + input: { + requestParameters, + requestArrayParameters, + body, + }, + event, + context, + interceptorContext: {}, + }); + + const marshal = (statusCode: number, responseBody: any): string => { + let marshalledBody = responseBody; + switch(statusCode) { + case 200: + break; + default: + break; + } + + return marshalledBody; + }; + + return { + ...response, + body: response.body ? marshal(response.statusCode, response.body) : '', + }; +}; +/** + * Single-value path/query parameters for Tag1 + */ +export interface Tag1RequestParameters { +} + +/** + * Multi-value query parameters for Tag1 + */ +export interface Tag1RequestArrayParameters { +} + +/** + * Request body parameter for Tag1 + */ +export type Tag1RequestBody = never; + +export type Tag1200OperationResponse = OperationResponse<200, undefined>; +export type Tag1OperationResponses = | Tag1200OperationResponse ; + +// Type that the handler function provided to the wrapper must conform to +export type Tag1HandlerFunction = LambdaHandlerFunction; +export type Tag1ChainedHandlerFunction = ChainedLambdaHandlerFunction; + +/** + * Lambda handler wrapper to provide typed interface for the implementation of tag1 + */ +export const tag1Handler = ( + firstHandler: Tag1ChainedHandlerFunction, + ...remainingHandlers: Tag1ChainedHandlerFunction[] +): OperationApiGatewayLambdaHandler<'tag1'> => async (event: any, context: any, _callback?: any, additionalInterceptors: Tag1ChainedHandlerFunction[] = []): Promise => { + const requestParameters = decodeRequestParameters({ + ...(event.pathParameters || {}), + ...(event.queryStringParameters || {}), + }) as unknown as Tag1RequestParameters; + + const requestArrayParameters = decodeRequestParameters({ + ...(event.multiValueQueryStringParameters || {}), + }) as unknown as Tag1RequestArrayParameters; + + const demarshal = (bodyString: string): any => { + return {}; + }; + const body = parseBody(event.body, demarshal, ['application/json']) as Tag1RequestBody; + + const chain = buildHandlerChain(...additionalInterceptors, firstHandler, ...remainingHandlers); + const response = await chain.next({ + input: { + requestParameters, + requestArrayParameters, + body, + }, + event, + context, + interceptorContext: {}, + }); + + const marshal = (statusCode: number, responseBody: any): string => { + let marshalledBody = responseBody; + switch(statusCode) { + case 200: + break; + default: + break; + } + + return marshalledBody; + }; + + return { + ...response, + body: response.body ? marshal(response.statusCode, response.body) : '', + }; +}; +/** + * Single-value path/query parameters for Tag2 + */ +export interface Tag2RequestParameters { +} + +/** + * Multi-value query parameters for Tag2 + */ +export interface Tag2RequestArrayParameters { +} + +/** + * Request body parameter for Tag2 + */ +export type Tag2RequestBody = never; + +export type Tag2200OperationResponse = OperationResponse<200, undefined>; +export type Tag2OperationResponses = | Tag2200OperationResponse ; + +// Type that the handler function provided to the wrapper must conform to +export type Tag2HandlerFunction = LambdaHandlerFunction; +export type Tag2ChainedHandlerFunction = ChainedLambdaHandlerFunction; + +/** + * Lambda handler wrapper to provide typed interface for the implementation of tag2 + */ +export const tag2Handler = ( + firstHandler: Tag2ChainedHandlerFunction, + ...remainingHandlers: Tag2ChainedHandlerFunction[] +): OperationApiGatewayLambdaHandler<'tag2'> => async (event: any, context: any, _callback?: any, additionalInterceptors: Tag2ChainedHandlerFunction[] = []): Promise => { + const requestParameters = decodeRequestParameters({ + ...(event.pathParameters || {}), + ...(event.queryStringParameters || {}), + }) as unknown as Tag2RequestParameters; + + const requestArrayParameters = decodeRequestParameters({ + ...(event.multiValueQueryStringParameters || {}), + }) as unknown as Tag2RequestArrayParameters; + + const demarshal = (bodyString: string): any => { + return {}; + }; + const body = parseBody(event.body, demarshal, ['application/json']) as Tag2RequestBody; + + const chain = buildHandlerChain(...additionalInterceptors, firstHandler, ...remainingHandlers); + const response = await chain.next({ + input: { + requestParameters, + requestArrayParameters, + body, + }, + event, + context, + interceptorContext: {}, + }); + + const marshal = (statusCode: number, responseBody: any): string => { + let marshalledBody = responseBody; + switch(statusCode) { + case 200: + break; + default: + break; + } + + return marshalledBody; + }; + + return { + ...response, + body: response.body ? marshal(response.statusCode, response.body) : '', + }; +}; + +export interface HandlerRouterHandlers { + readonly neither: OperationApiGatewayLambdaHandler<'neither'>; + readonly both: OperationApiGatewayLambdaHandler<'both'>; + readonly tag1: OperationApiGatewayLambdaHandler<'tag1'>; + readonly tag2: OperationApiGatewayLambdaHandler<'tag2'>; +} + +export type AnyOperationRequestParameters = | NeitherRequestParameters| BothRequestParameters| Tag1RequestParameters| Tag2RequestParameters; +export type AnyOperationRequestArrayParameters = | NeitherRequestArrayParameters| BothRequestArrayParameters| Tag1RequestArrayParameters| Tag2RequestArrayParameters; +export type AnyOperationRequestBodies = | NeitherRequestBody| BothRequestBody| Tag1RequestBody| Tag2RequestBody; +export type AnyOperationResponses = | NeitherOperationResponses| BothOperationResponses| Tag1OperationResponses| Tag2OperationResponses; + +export interface HandlerRouterProps< + RequestParameters, + RequestArrayParameters, + RequestBody, + Response extends AnyOperationResponses +> { + /** + * Interceptors to apply to all handlers + */ + readonly interceptors?: ChainedLambdaHandlerFunction< + RequestParameters, + RequestArrayParameters, + RequestBody, + Response + >[]; + + /** + * Handlers to register for each operation + */ + readonly handlers: HandlerRouterHandlers; +} + +const concatMethodAndPath = (method: string, path: string) => \`\${method.toLowerCase()}||\${path}\`; -export function TestRequestToJSON(value?: TestRequest | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'myInput': value.myInput, - }; -} +const OperationIdByMethodAndPath = Object.fromEntries(Object.entries(OperationLookup).map( + ([operationId, methodAndPath]) => [concatMethodAndPath(methodAndPath.method, methodAndPath.path), operationId] +)); +/** + * Returns a lambda handler which can be used to route requests to the appropriate typed lambda handler function. + */ +export const handlerRouter = (props: HandlerRouterProps< + AnyOperationRequestParameters, + AnyOperationRequestArrayParameters, + AnyOperationRequestBodies, + AnyOperationResponses +>): OperationApiGatewayLambdaHandler => async (event, context) => { + const operationId = OperationIdByMethodAndPath[concatMethodAndPath(event.requestContext.httpMethod, event.requestContext.resourcePath)]; + const handler = props.handlers[operationId]; + return handler(event, context, undefined, props.interceptors); +}; ", - "src/models/TestResponse.ts": "/* tslint:disable */ + "src/apis/Tag1Api.ts": "/* tslint:disable */ /* eslint-disable */ /** - * Example API + * Multiple Tags Test * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 @@ -1704,61 +4107,66 @@ export function TestRequestToJSON(value?: TestRequest | null): any { * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; -import { - TestResponseMessagesInner, - TestResponseMessagesInnerFromJSON, - TestResponseMessagesInnerFromJSONTyped, - TestResponseMessagesInnerToJSON, -} from './TestResponseMessagesInner'; + +import * as runtime from '../runtime'; /** * - * @export - * @interface TestResponse */ -export interface TestResponse { +export class Tag1Api extends runtime.BaseAPI { + /** - * - * @type {Array} - * @memberof TestResponse */ - messages: Array; -} + async bothRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + const headerParameters: runtime.HTTPHeaders = {}; -export function TestResponseFromJSON(json: any): TestResponse { - return TestResponseFromJSONTyped(json, false); -} + const response = await this.request({ + path: \`/both\`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); -export function TestResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestResponse { - if ((json === undefined) || (json === null)) { - return json; + return new runtime.VoidApiResponse(response); } - return { - - 'messages': ((json['messages'] as Array).map(TestResponseMessagesInnerFromJSON)), - }; -} -export function TestResponseToJSON(value?: TestResponse | null): any { - if (value === undefined) { - return undefined; + /** + */ + async both(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.bothRaw(initOverrides); } - if (value === null) { - return null; + + /** + */ + async tag1Raw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: \`/tag1\`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.VoidApiResponse(response); + } + + /** + */ + async tag1(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.tag1Raw(initOverrides); } - return { - - 'messages': ((value.messages as Array).map(TestResponseMessagesInnerToJSON)), - }; -} +} ", - "src/models/TestResponseMessagesInner.ts": "/* tslint:disable */ + "src/apis/Tag2Api.ts": "/* tslint:disable */ /* eslint-disable */ /** - * Example API + * Multiple Tags Test * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 @@ -1769,69 +4177,55 @@ export function TestResponseToJSON(value?: TestResponse | null): any { * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; + +import * as runtime from '../runtime'; + /** * - * @export - * @interface TestResponseMessagesInner */ -export interface TestResponseMessagesInner { - /** - * - * @type {string} - * @memberof TestResponseMessagesInner - */ - message?: string; +export class Tag2Api extends runtime.BaseAPI { + /** - * - * @type {number} - * @memberof TestResponseMessagesInner */ - id: number; -} + async tag2Raw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const queryParameters: any = {}; + const headerParameters: runtime.HTTPHeaders = {}; -export function TestResponseMessagesInnerFromJSON(json: any): TestResponseMessagesInner { - return TestResponseMessagesInnerFromJSONTyped(json, false); -} + const response = await this.request({ + path: \`/tag2\`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); -export function TestResponseMessagesInnerFromJSONTyped(json: any, ignoreDiscriminator: boolean): TestResponseMessagesInner { - if ((json === undefined) || (json === null)) { - return json; + return new runtime.VoidApiResponse(response); } - return { - - 'message': !exists(json, 'message') ? undefined : json['message'], - 'id': json['id'], - }; -} -export function TestResponseMessagesInnerToJSON(value?: TestResponseMessagesInner | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; + /** + */ + async tag2(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + await this.tag2Raw(initOverrides); } - return { - - 'message': value.message, - 'id': value.id, - }; -} +} ", - "src/models/index.ts": "/* tslint:disable */ + "src/apis/index.ts": "/* tslint:disable */ /* eslint-disable */ -export * from './ApiError'; -export * from './TestRequest'; -export * from './TestResponse'; -export * from './TestResponseMessagesInner'; +export * from './DefaultApi'; +export * from './Tag1Api'; +export * from './Tag2Api'; ", + "src/index.ts": "/* tslint:disable */ +/* eslint-disable */ +export * from './runtime'; +export * from './apis'; +export * from './models'; +export * from './apis/DefaultApi/OperationConfig';", "src/runtime.ts": "/* tslint:disable */ /* eslint-disable */ /** - * Example API + * Multiple Tags Test * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 @@ -1943,16 +4337,16 @@ export class BaseAPI { return this.withMiddleware(...middlewares); } - protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction): Promise { + protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise { const { url, init } = await this.createFetchParams(context, initOverrides); const response = await this.fetchApi(url, init); - if (response.status >= 200 && response.status < 300) { + if (response && (response.status >= 200 && response.status < 300)) { return response; } throw new ResponseError(response, 'Response returned an error code'); } - private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction) { + private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) { let url = this.configuration.basePath + context.path; if (context.query !== undefined && Object.keys(context.query).length !== 0) { // only add the querystring to the URL if there are query parameters. @@ -1976,22 +4370,22 @@ export class BaseAPI { credentials: this.configuration.credentials, }; - const overridedInit: RequestInit = { + const overriddenInit: RequestInit = { ...initParams, ...(await initOverrideFn({ init: initParams, context, })) - } + }; const init: RequestInit = { - ...overridedInit, + ...overriddenInit, body: - isFormData(overridedInit.body) || - overridedInit.body instanceof URLSearchParams || - isBlob(overridedInit.body) - ? overridedInit.body - : JSON.stringify(overridedInit.body), + isFormData(overriddenInit.body) || + overriddenInit.body instanceof URLSearchParams || + isBlob(overriddenInit.body) + ? overriddenInit.body + : JSON.stringify(overriddenInit.body), }; return { url, init }; @@ -2007,7 +4401,29 @@ export class BaseAPI { }) || fetchParams; } } - let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + let response: Response | undefined = undefined; + try { + response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + } catch (e) { + for (const middleware of this.middleware) { + if (middleware.onError) { + response = await middleware.onError({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + error: e, + response: response ? response.clone() : undefined, + }) || response; + } + } + if (response === undefined) { + if (e instanceof Error) { + throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); + } else { + throw e; + } + } + } for (const middleware of this.middleware) { if (middleware.post) { response = await middleware.post({ @@ -2034,22 +4450,29 @@ export class BaseAPI { }; function isBlob(value: any): value is Blob { - return typeof Blob !== 'undefined' && value instanceof Blob + return typeof Blob !== 'undefined' && value instanceof Blob; } function isFormData(value: any): value is FormData { - return typeof FormData !== \\"undefined\\" && value instanceof FormData + return typeof FormData !== \\"undefined\\" && value instanceof FormData; } export class ResponseError extends Error { - name: \\"ResponseError\\" = \\"ResponseError\\"; + override name: \\"ResponseError\\" = \\"ResponseError\\"; constructor(public response: Response, msg?: string) { super(msg); } } +export class FetchError extends Error { + override name: \\"FetchError\\" = \\"FetchError\\"; + constructor(public cause: Error, msg?: string) { + super(msg); + } +} + export class RequiredError extends Error { - name: \\"RequiredError\\" = \\"RequiredError\\"; + override name: \\"RequiredError\\" = \\"RequiredError\\"; constructor(public field: string, msg?: string) { super(msg); } @@ -2069,10 +4492,10 @@ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' export type HTTPHeaders = { [key: string]: string }; export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery }; export type HTTPBody = Json | FormData | URLSearchParams; -export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody } +export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }; export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; -export type InitOverideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise +export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise export interface FetchParams { url: string; @@ -2099,7 +4522,7 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join('&'); } -function querystringSingleKey(key: string, value: string | number | null | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { +function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { const fullKey = keyPrefix + (keyPrefix.length ? \`[\${key}]\` : key); if (value instanceof Array) { const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) @@ -2136,7 +4559,7 @@ export function canConsumeForm(consumes: Consume[]): boolean { } export interface Consume { - contentType: string + contentType: string; } export interface RequestContext { @@ -2152,9 +4575,18 @@ export interface ResponseContext { response: Response; } +export interface ErrorContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + error: unknown; + response?: Response; +} + export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; + onError?(context: ErrorContext): Promise; } export interface ApiResponse { @@ -2264,8 +4696,6 @@ test('hello', () => { } `; -exports[`Generated Typescript Client Code Unit Tests Multiple Tags 1`] = `"Operations with multiple tags are not yet supported, please tag operations with at most one tag. The following operations have multiple tags: get /both"`; - exports[`Generated Typescript Client Code Unit Tests Single 1`] = ` Object { ".eslintrc.json": Object { @@ -2859,7 +5289,7 @@ src/runtime.ts tsconfig.esm.json tsconfig.json ", - ".openapi-generator/VERSION": "6.0.0", + ".openapi-generator/VERSION": "6.3.0", ".projen/deps.json": Object { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", "dependencies": Array [ @@ -3493,14 +5923,16 @@ npm install PATH_TO_GENERATED_PACKAGE --save import * as runtime from '../runtime'; +import type { + ApiError, + TestRequest, + TestResponse, +} from '../models'; import { - ApiError, ApiErrorFromJSON, ApiErrorToJSON, - TestRequest, TestRequestFromJSON, TestRequestToJSON, - TestResponse, TestResponseFromJSON, TestResponseToJSON, } from '../models'; @@ -3529,7 +5961,7 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async anyRequestResponseRaw(requestParameters: AnyRequestResponseRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async anyRequestResponseRaw(requestParameters: AnyRequestResponseRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -3549,14 +5981,14 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async anyRequestResponse(requestParameters: AnyRequestResponseRequest = {}, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async anyRequestResponse(requestParameters: AnyRequestResponseRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.anyRequestResponseRaw(requestParameters, initOverrides); return await response.value(); } /** */ - async emptyRaw(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async emptyRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -3573,13 +6005,13 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async empty(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async empty(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.emptyRaw(initOverrides); } /** */ - async mediaTypesRaw(requestParameters: MediaTypesRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async mediaTypesRaw(requestParameters: MediaTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.body === null || requestParameters.body === undefined) { throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling mediaTypes.'); } @@ -3603,14 +6035,14 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async mediaTypes(requestParameters: MediaTypesRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async mediaTypes(requestParameters: MediaTypesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.mediaTypesRaw(requestParameters, initOverrides); return await response.value(); } /** */ - async operationOneRaw(requestParameters: OperationOneRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async operationOneRaw(requestParameters: OperationOneRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (requestParameters.param1 === null || requestParameters.param1 === undefined) { throw new runtime.RequiredError('param1','Required parameter requestParameters.param1 was null or undefined when calling operationOne.'); } @@ -3666,14 +6098,14 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async operationOne(requestParameters: OperationOneRequest, initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async operationOne(requestParameters: OperationOneRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.operationOneRaw(requestParameters, initOverrides); return await response.value(); } /** */ - async withoutOperationIdDeleteRaw(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async withoutOperationIdDeleteRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -3690,7 +6122,7 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async withoutOperationIdDelete(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async withoutOperationIdDelete(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.withoutOperationIdDeleteRaw(initOverrides); return await response.value(); } @@ -4344,6 +6776,16 @@ export interface ApiError { } +/** + * Check if a given object implements the ApiError interface. + */ +export function instanceOfApiError(value: object): boolean { + let isInstance = true; + isInstance = isInstance && \\"errorMessage\\" in value; + + return isInstance; +} + export function ApiErrorFromJSON(json: any): ApiError { return ApiErrorFromJSONTyped(json, false); } @@ -4402,6 +6844,15 @@ export interface TestRequest { } +/** + * Check if a given object implements the TestRequest interface. + */ +export function instanceOfTestRequest(value: object): boolean { + let isInstance = true; + + return isInstance; +} + export function TestRequestFromJSON(json: any): TestRequest { return TestRequestFromJSONTyped(json, false); } @@ -4445,8 +6896,8 @@ export function TestRequestToJSON(value?: TestRequest | null): any { */ import { exists, mapValues } from '../runtime'; +import type { TestResponseMessagesInner } from './TestResponseMessagesInner'; import { - TestResponseMessagesInner, TestResponseMessagesInnerFromJSON, TestResponseMessagesInnerFromJSONTyped, TestResponseMessagesInnerToJSON, @@ -4467,6 +6918,16 @@ export interface TestResponse { } +/** + * Check if a given object implements the TestResponse interface. + */ +export function instanceOfTestResponse(value: object): boolean { + let isInstance = true; + isInstance = isInstance && \\"messages\\" in value; + + return isInstance; +} + export function TestResponseFromJSON(json: any): TestResponse { return TestResponseFromJSONTyped(json, false); } @@ -4531,6 +6992,16 @@ export interface TestResponseMessagesInner { } +/** + * Check if a given object implements the TestResponseMessagesInner interface. + */ +export function instanceOfTestResponseMessagesInner(value: object): boolean { + let isInstance = true; + isInstance = isInstance && \\"id\\" in value; + + return isInstance; +} + export function TestResponseMessagesInnerFromJSON(json: any): TestResponseMessagesInner { return TestResponseMessagesInnerFromJSONTyped(json, false); } @@ -4683,16 +7154,16 @@ export class BaseAPI { return this.withMiddleware(...middlewares); } - protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction): Promise { + protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise { const { url, init } = await this.createFetchParams(context, initOverrides); const response = await this.fetchApi(url, init); - if (response.status >= 200 && response.status < 300) { + if (response && (response.status >= 200 && response.status < 300)) { return response; } throw new ResponseError(response, 'Response returned an error code'); } - private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction) { + private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) { let url = this.configuration.basePath + context.path; if (context.query !== undefined && Object.keys(context.query).length !== 0) { // only add the querystring to the URL if there are query parameters. @@ -4716,22 +7187,22 @@ export class BaseAPI { credentials: this.configuration.credentials, }; - const overridedInit: RequestInit = { + const overriddenInit: RequestInit = { ...initParams, ...(await initOverrideFn({ init: initParams, context, })) - } + }; const init: RequestInit = { - ...overridedInit, + ...overriddenInit, body: - isFormData(overridedInit.body) || - overridedInit.body instanceof URLSearchParams || - isBlob(overridedInit.body) - ? overridedInit.body - : JSON.stringify(overridedInit.body), + isFormData(overriddenInit.body) || + overriddenInit.body instanceof URLSearchParams || + isBlob(overriddenInit.body) + ? overriddenInit.body + : JSON.stringify(overriddenInit.body), }; return { url, init }; @@ -4747,7 +7218,29 @@ export class BaseAPI { }) || fetchParams; } } - let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + let response: Response | undefined = undefined; + try { + response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + } catch (e) { + for (const middleware of this.middleware) { + if (middleware.onError) { + response = await middleware.onError({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + error: e, + response: response ? response.clone() : undefined, + }) || response; + } + } + if (response === undefined) { + if (e instanceof Error) { + throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); + } else { + throw e; + } + } + } for (const middleware of this.middleware) { if (middleware.post) { response = await middleware.post({ @@ -4774,22 +7267,29 @@ export class BaseAPI { }; function isBlob(value: any): value is Blob { - return typeof Blob !== 'undefined' && value instanceof Blob + return typeof Blob !== 'undefined' && value instanceof Blob; } function isFormData(value: any): value is FormData { - return typeof FormData !== \\"undefined\\" && value instanceof FormData + return typeof FormData !== \\"undefined\\" && value instanceof FormData; } export class ResponseError extends Error { - name: \\"ResponseError\\" = \\"ResponseError\\"; + override name: \\"ResponseError\\" = \\"ResponseError\\"; constructor(public response: Response, msg?: string) { super(msg); } } +export class FetchError extends Error { + override name: \\"FetchError\\" = \\"FetchError\\"; + constructor(public cause: Error, msg?: string) { + super(msg); + } +} + export class RequiredError extends Error { - name: \\"RequiredError\\" = \\"RequiredError\\"; + override name: \\"RequiredError\\" = \\"RequiredError\\"; constructor(public field: string, msg?: string) { super(msg); } @@ -4809,10 +7309,10 @@ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' export type HTTPHeaders = { [key: string]: string }; export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery }; export type HTTPBody = Json | FormData | URLSearchParams; -export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody } +export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }; export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; -export type InitOverideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise +export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise export interface FetchParams { url: string; @@ -4839,7 +7339,7 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join('&'); } -function querystringSingleKey(key: string, value: string | number | null | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { +function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { const fullKey = keyPrefix + (keyPrefix.length ? \`[\${key}]\` : key); if (value instanceof Array) { const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) @@ -4876,7 +7376,7 @@ export function canConsumeForm(consumes: Consume[]): boolean { } export interface Consume { - contentType: string + contentType: string; } export interface RequestContext { @@ -4892,9 +7392,18 @@ export interface ResponseContext { response: Response; } +export interface ErrorContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + error: unknown; + response?: Response; +} + export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; + onError?(context: ErrorContext): Promise; } export interface ApiResponse { @@ -5586,7 +8095,7 @@ src/runtime.ts tsconfig.esm.json tsconfig.json ", - ".openapi-generator/VERSION": "6.0.0", + ".openapi-generator/VERSION": "6.3.0", ".projen/deps.json": Object { "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\".", "dependencies": Array [ @@ -6228,7 +8737,7 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async neitherRaw(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async neitherRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -6245,7 +8754,7 @@ export class DefaultApi extends runtime.BaseAPI { /** */ - async neither(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async neither(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.neitherRaw(initOverrides); } @@ -6778,7 +9287,7 @@ export class Tag1Api extends runtime.BaseAPI { /** */ - async tag1Raw(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async tag1Raw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -6795,13 +9304,13 @@ export class Tag1Api extends runtime.BaseAPI { /** */ - async tag1(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async tag1(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.tag1Raw(initOverrides); } /** */ - async tag1AgainRaw(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async tag1AgainRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -6818,7 +9327,7 @@ export class Tag1Api extends runtime.BaseAPI { /** */ - async tag1Again(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async tag1Again(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.tag1AgainRaw(initOverrides); } @@ -6848,7 +9357,7 @@ export class Tag2Api extends runtime.BaseAPI { /** */ - async tag2Raw(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise> { + async tag2Raw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; @@ -6865,7 +9374,7 @@ export class Tag2Api extends runtime.BaseAPI { /** */ - async tag2(initOverrides?: RequestInit | runtime.InitOverideFunction): Promise { + async tag2(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.tag2Raw(initOverrides); } @@ -6998,16 +9507,16 @@ export class BaseAPI { return this.withMiddleware(...middlewares); } - protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction): Promise { + protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise { const { url, init } = await this.createFetchParams(context, initOverrides); const response = await this.fetchApi(url, init); - if (response.status >= 200 && response.status < 300) { + if (response && (response.status >= 200 && response.status < 300)) { return response; } throw new ResponseError(response, 'Response returned an error code'); } - private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverideFunction) { + private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) { let url = this.configuration.basePath + context.path; if (context.query !== undefined && Object.keys(context.query).length !== 0) { // only add the querystring to the URL if there are query parameters. @@ -7031,22 +9540,22 @@ export class BaseAPI { credentials: this.configuration.credentials, }; - const overridedInit: RequestInit = { + const overriddenInit: RequestInit = { ...initParams, ...(await initOverrideFn({ init: initParams, context, })) - } + }; const init: RequestInit = { - ...overridedInit, + ...overriddenInit, body: - isFormData(overridedInit.body) || - overridedInit.body instanceof URLSearchParams || - isBlob(overridedInit.body) - ? overridedInit.body - : JSON.stringify(overridedInit.body), + isFormData(overriddenInit.body) || + overriddenInit.body instanceof URLSearchParams || + isBlob(overriddenInit.body) + ? overriddenInit.body + : JSON.stringify(overriddenInit.body), }; return { url, init }; @@ -7062,7 +9571,29 @@ export class BaseAPI { }) || fetchParams; } } - let response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + let response: Response | undefined = undefined; + try { + response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init); + } catch (e) { + for (const middleware of this.middleware) { + if (middleware.onError) { + response = await middleware.onError({ + fetch: this.fetchApi, + url: fetchParams.url, + init: fetchParams.init, + error: e, + response: response ? response.clone() : undefined, + }) || response; + } + } + if (response === undefined) { + if (e instanceof Error) { + throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response'); + } else { + throw e; + } + } + } for (const middleware of this.middleware) { if (middleware.post) { response = await middleware.post({ @@ -7089,22 +9620,29 @@ export class BaseAPI { }; function isBlob(value: any): value is Blob { - return typeof Blob !== 'undefined' && value instanceof Blob + return typeof Blob !== 'undefined' && value instanceof Blob; } function isFormData(value: any): value is FormData { - return typeof FormData !== \\"undefined\\" && value instanceof FormData + return typeof FormData !== \\"undefined\\" && value instanceof FormData; } export class ResponseError extends Error { - name: \\"ResponseError\\" = \\"ResponseError\\"; + override name: \\"ResponseError\\" = \\"ResponseError\\"; constructor(public response: Response, msg?: string) { super(msg); } } +export class FetchError extends Error { + override name: \\"FetchError\\" = \\"FetchError\\"; + constructor(public cause: Error, msg?: string) { + super(msg); + } +} + export class RequiredError extends Error { - name: \\"RequiredError\\" = \\"RequiredError\\"; + override name: \\"RequiredError\\" = \\"RequiredError\\"; constructor(public field: string, msg?: string) { super(msg); } @@ -7124,10 +9662,10 @@ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' export type HTTPHeaders = { [key: string]: string }; export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery }; export type HTTPBody = Json | FormData | URLSearchParams; -export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody } +export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody }; export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original'; -export type InitOverideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise +export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise export interface FetchParams { url: string; @@ -7154,7 +9692,7 @@ export function querystring(params: HTTPQuery, prefix: string = ''): string { .join('&'); } -function querystringSingleKey(key: string, value: string | number | null | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { +function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string { const fullKey = keyPrefix + (keyPrefix.length ? \`[\${key}]\` : key); if (value instanceof Array) { const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue))) @@ -7191,7 +9729,7 @@ export function canConsumeForm(consumes: Consume[]): boolean { } export interface Consume { - contentType: string + contentType: string; } export interface RequestContext { @@ -7207,9 +9745,18 @@ export interface ResponseContext { response: Response; } +export interface ErrorContext { + fetch: FetchAPI; + url: string; + init: RequestInit; + error: unknown; + response?: Response; +} + export interface Middleware { pre?(context: RequestContext): Promise; post?(context: ResponseContext): Promise; + onError?(context: ErrorContext): Promise; } export interface ApiResponse { diff --git a/packages/open-api-gateway/test/project/codegen/components/docs/__snapshots__/generated-html2-docs.test.ts.snap b/packages/open-api-gateway/test/project/codegen/components/docs/__snapshots__/generated-html2-docs.test.ts.snap index 2492b5b34..c47d31836 100644 --- a/packages/open-api-gateway/test/project/codegen/components/docs/__snapshots__/generated-html2-docs.test.ts.snap +++ b/packages/open-api-gateway/test/project/codegen/components/docs/__snapshots__/generated-html2-docs.test.ts.snap @@ -111,7 +111,7 @@ node_modules/ "html2/.openapi-generator/FILES": ".openapi-generator-ignore index.html ", - "html2/.openapi-generator/VERSION": "6.0.0", + "html2/.openapi-generator/VERSION": "6.3.0", "html2/index.html": " @@ -1082,10 +1082,7 @@ ul.nav-tabs {
curl -X POST \\\\
  -H \\"Accept: application/json\\" \\\\
  -H \\"Content-Type: application/json\\" \\\\
- \\"http://localhost/operation/{pathParam}\\" \\\\
- -d '{
-  "myInput" : 0.8008281904610115
-}'
+ \\"http://localhost/operation/{pathParam}\\"
 
@@ -1402,22 +1399,18 @@ $(document).ready(function() {