diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index daef5f47de5..9a294f54a8d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -151,6 +151,7 @@ public class DefaultCodegen implements CodegenConfig { protected String outputFolder = ""; protected Set defaultIncludes; protected Map typeMapping; + // instantiationTypes map from container types only: set, map, and array to the in language-type protected Map instantiationTypes; protected Set reservedWords; protected Set languageSpecificPrimitives = new HashSet<>(); @@ -281,6 +282,16 @@ public class DefaultCodegen implements CodegenConfig { protected boolean loadDeepObjectIntoItems = true; + // if true then baseTypes will be imported + protected boolean importBaseType = true; + + // if true then container types will be imported + protected boolean importContainerType = true; + + // if True codegenParameter and codegenResponse imports will come + // from deeper schema defined locations + protected boolean addSchemaImportsFromV3SpecLocations = false; + @Override public List cliOptions() { return cliOptions; @@ -288,6 +299,7 @@ public class DefaultCodegen implements CodegenConfig { @Override public void processOpts() { + if (additionalProperties.containsKey(CodegenConstants.TEMPLATE_DIR)) { this.setTemplateDir((String) additionalProperties.get(CodegenConstants.TEMPLATE_DIR)); } @@ -2949,6 +2961,9 @@ public class DefaultCodegen implements CodegenConfig { } } + if (addSchemaImportsFromV3SpecLocations) { + addImports(m.imports, m.getImports(importContainerType, importBaseType, generatorMetadata.getFeatureSet())); + } return m; } @@ -4173,14 +4188,16 @@ public class DefaultCodegen implements CodegenConfig { String mediaTypeSchemaSuffix = String.format(Locale.ROOT, "%sResponseBody", r.code); r.setContent(getContent(response.getContent(), imports, mediaTypeSchemaSuffix)); - if (r.baseType != null && - !defaultIncludes.contains(r.baseType) && - !languageSpecificPrimitives.contains(r.baseType)) { - imports.add(r.baseType); - } - if ("set".equals(r.containerType) && typeMapping.containsKey(r.containerType)) { - op.uniqueItems = true; - imports.add(typeMapping.get(r.containerType)); + if (!addSchemaImportsFromV3SpecLocations) { + if (r.baseType != null && + !defaultIncludes.contains(r.baseType) && + !languageSpecificPrimitives.contains(r.baseType)) { + imports.add(r.baseType); + } + if ("set".equals(r.containerType) && typeMapping.containsKey(r.containerType)) { + op.uniqueItems = true; + imports.add(typeMapping.get(r.containerType)); + } } op.responses.add(r); @@ -4669,10 +4686,12 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.isContainer = true; codegenParameter.isMap = true; - // recursively add import - while (codegenProperty != null) { - imports.add(codegenProperty.baseType); - codegenProperty = codegenProperty.items; + if (!addSchemaImportsFromV3SpecLocations) { + // recursively add import + while (codegenProperty != null) { + imports.add(codegenProperty.baseType); + codegenProperty = codegenProperty.items; + } } } @@ -4757,6 +4776,9 @@ public class DefaultCodegen implements CodegenConfig { prop = fromProperty(parameter.getName(), parameterSchema, false); } codegenParameter.setSchema(prop); + if (addSchemaImportsFromV3SpecLocations) { + addImports(imports, prop.getImports(importContainerType, importBaseType, generatorMetadata.getFeatureSet())); + } } else if (parameter.getContent() != null) { Content content = parameter.getContent(); if (content.size() > 1) { @@ -4790,7 +4812,7 @@ public class DefaultCodegen implements CodegenConfig { return codegenParameter; } - // TODO need to reivew replacing empty map with schemaMapping instead + // TODO need to review replacing empty map with schemaMapping instead parameterSchema = unaliasSchema(parameterSchema); if (parameterSchema == null) { LOGGER.warn("warning! Schema not found for parameter \" {} \"", parameter.getName()); @@ -4882,11 +4904,12 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.mostInnerItems = itemsProperty.mostInnerItems; codegenParameter.baseType = itemsProperty.dataType; codegenParameter.isContainer = true; - - // recursively add import - while (itemsProperty != null) { - imports.add(itemsProperty.baseType); - itemsProperty = itemsProperty.items; + if (!addSchemaImportsFromV3SpecLocations) { + // recursively add import + while (itemsProperty != null) { + imports.add(itemsProperty.baseType); + itemsProperty = itemsProperty.items; + } } } else { // referenced schemas @@ -4906,8 +4929,10 @@ public class DefaultCodegen implements CodegenConfig { } else { codegenParameter.dataType = codegenProperty.dataType; } - if (ModelUtils.isSet(parameterSchema)) { - imports.add(codegenProperty.baseType); + if (!addSchemaImportsFromV3SpecLocations) { + if (ModelUtils.isSet(parameterSchema)) { + imports.add(codegenProperty.baseType); + } } codegenParameter.dataFormat = codegenProperty.dataFormat; if (parameter.getRequired() != null) { @@ -4937,10 +4962,11 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.isCollectionFormatMulti = true; } codegenParameter.paramName = toParamName(parameter.getName()); - - // import - if (codegenProperty.complexType != null) { - imports.add(codegenProperty.complexType); + if (!addSchemaImportsFromV3SpecLocations) { + // import + if (codegenProperty.complexType != null) { + imports.add(codegenProperty.complexType); + } } codegenParameter.pattern = toRegularExpression(parameterSchema.getPattern()); @@ -5311,15 +5337,17 @@ public class DefaultCodegen implements CodegenConfig { final CodegenProperty property = fromProperty(name, schema, false); addImport(model, property.complexType); model.parent = toInstantiationType(schema); - final String containerType = property.containerType; - final String instantiationType = instantiationTypes.get(containerType); - if (instantiationType != null) { - addImport(model, instantiationType); - } + if (!addSchemaImportsFromV3SpecLocations) { + final String containerType = property.containerType; + final String instantiationType = instantiationTypes.get(containerType); + if (instantiationType != null) { + addImport(model, instantiationType); + } - final String mappedType = typeMapping.get(containerType); - if (mappedType != null) { - addImport(model, mappedType); + final String mappedType = typeMapping.get(containerType); + if (mappedType != null) { + addImport(model, mappedType); + } } } @@ -5350,7 +5378,7 @@ public class DefaultCodegen implements CodegenConfig { } protected void addImports(Set importsToBeAddedTo, IJsonSchemaValidationProperties type) { - addImports(importsToBeAddedTo, type.getImports(true)); + addImports(importsToBeAddedTo, type.getImports(importContainerType, importBaseType, generatorMetadata.getFeatureSet())); } protected void addImports(Set importsToBeAddedTo, Set importsToAdd) { @@ -5519,8 +5547,9 @@ public class DefaultCodegen implements CodegenConfig { if (!Boolean.TRUE.equals(cp.isReadOnly)) { cm.hasOnlyReadOnly = false; } - - addImportsForPropertyType(cm, cp); + if (!addSchemaImportsFromV3SpecLocations) { + addImportsForPropertyType(cm, cp); + } // if required, add to the list "requiredVars" if (Boolean.FALSE.equals(cp.required)) { @@ -6658,10 +6687,12 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.collectionFormat = StringUtils.isEmpty(collectionFormat) ? "csv" : collectionFormat; codegenParameter.isCollectionFormatMulti = "multi".equals(collectionFormat); - // recursively add import - while (arrayInnerProperty != null) { - imports.add(arrayInnerProperty.baseType); - arrayInnerProperty = arrayInnerProperty.items; + if (!addSchemaImportsFromV3SpecLocations) { + // recursively add import + while (arrayInnerProperty != null) { + imports.add(arrayInnerProperty.baseType); + arrayInnerProperty = arrayInnerProperty.items; + } } } else { // referenced schemas @@ -6689,11 +6720,12 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.enumName = codegenProperty.enumName; } - // import - if (codegenProperty.complexType != null) { - imports.add(codegenProperty.complexType); + if (!addSchemaImportsFromV3SpecLocations) { + // import + if (codegenProperty.complexType != null) { + imports.add(codegenProperty.complexType); + } } - setParameterExampleValue(codegenParameter); // set nullable setParameterNullable(codegenParameter, codegenProperty); @@ -6722,13 +6754,18 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.dataType = getTypeDeclaration(codegenModel.classname); codegenParameter.description = codegenModel.description; codegenParameter.isNullable = codegenModel.isNullable; - imports.add(codegenParameter.baseType); + if (!addSchemaImportsFromV3SpecLocations) { + imports.add(codegenParameter.baseType); + } } else { CodegenProperty codegenProperty = fromProperty("property", schema, false); if (codegenProperty != null && codegenProperty.getComplexType() != null && codegenProperty.getComplexType().contains(" | ")) { - List parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| ")); - imports.addAll(parts); + if (!addSchemaImportsFromV3SpecLocations) { + // TODO move this splitting logic to the generator that needs it only + List parts = Arrays.asList(codegenProperty.getComplexType().split(" \\| ")); + imports.addAll(parts); + } String codegenModelName = codegenProperty.getComplexType(); codegenParameter.baseName = codegenModelName; codegenParameter.paramName = toParamName(codegenParameter.baseName); @@ -6766,10 +6803,12 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.baseType = codegenModelName; codegenParameter.dataType = getTypeDeclaration(codegenModelName); codegenParameter.description = codegenModelDescription; - imports.add(codegenParameter.baseType); + if (!addSchemaImportsFromV3SpecLocations) { + imports.add(codegenParameter.baseType); - if (codegenProperty.complexType != null) { - imports.add(codegenProperty.complexType); + if (codegenProperty.complexType != null) { + imports.add(codegenProperty.complexType); + } } } } @@ -6791,14 +6830,15 @@ public class DefaultCodegen implements CodegenConfig { } CodegenProperty codegenProperty = fromProperty("property", schema, false); - imports.add(codegenProperty.baseType); - - CodegenProperty innerCp = codegenProperty; - while (innerCp != null) { - if (innerCp.complexType != null) { - imports.add(innerCp.complexType); + if (!addSchemaImportsFromV3SpecLocations) { + imports.add(codegenProperty.baseType); + CodegenProperty innerCp = codegenProperty; + while (innerCp != null) { + if (innerCp.complexType != null) { + imports.add(innerCp.complexType); + } + innerCp = innerCp.items; } - innerCp = innerCp.items; } if (StringUtils.isEmpty(bodyParameterName)) { @@ -6836,10 +6876,11 @@ public class DefaultCodegen implements CodegenConfig { codegenParameter.pattern = codegenProperty.pattern; codegenParameter.isNullable = codegenProperty.isNullable; - if (codegenProperty.complexType != null) { - imports.add(codegenProperty.complexType); + if (!addSchemaImportsFromV3SpecLocations) { + if (codegenProperty.complexType != null) { + imports.add(codegenProperty.complexType); + } } - } // set nullable setParameterNullable(codegenParameter, codegenProperty); @@ -6885,14 +6926,18 @@ public class DefaultCodegen implements CodegenConfig { final ArraySchema arraySchema = (ArraySchema) schema; Schema inner = getSchemaItems(arraySchema); CodegenProperty codegenProperty = fromProperty("property", arraySchema, false); - imports.add(codegenProperty.baseType); + if (!addSchemaImportsFromV3SpecLocations) { + imports.add(codegenProperty.baseType); + } CodegenProperty innerCp = codegenProperty; CodegenProperty mostInnerItem = innerCp; // loop through multidimensional array to add proper import // also find the most inner item while (innerCp != null) { - if (innerCp.complexType != null) { - imports.add(innerCp.complexType); + if (!addSchemaImportsFromV3SpecLocations) { + if (innerCp.complexType != null) { + imports.add(innerCp.complexType); + } } mostInnerItem = innerCp; innerCp = innerCp.items; @@ -6918,9 +6963,11 @@ public class DefaultCodegen implements CodegenConfig { // set nullable setParameterNullable(codegenParameter, codegenProperty); - while (codegenProperty != null) { - imports.add(codegenProperty.baseType); - codegenProperty = codegenProperty.items; + if (!addSchemaImportsFromV3SpecLocations) { + while (codegenProperty != null) { + imports.add(codegenProperty.baseType); + codegenProperty = codegenProperty.items; + } } } } @@ -7036,7 +7083,11 @@ public class DefaultCodegen implements CodegenConfig { CodegenMediaType codegenMt = new CodegenMediaType(schemaProp, ceMap, schemaTestCases); cmtContent.put(contentType, codegenMt); if (schemaProp != null) { - addImports(imports, schemaProp.getImports(false)); + if (addSchemaImportsFromV3SpecLocations) { + addImports(imports, schemaProp.getImports(importContainerType, importBaseType, generatorMetadata.getFeatureSet())); + } else { + addImports(imports, schemaProp.getImports(false, importBaseType, generatorMetadata.getFeatureSet())); + } } } return cmtContent; @@ -7127,6 +7178,7 @@ public class DefaultCodegen implements CodegenConfig { updateRequestBodyForPrimitiveType(codegenParameter, schema, bodyParameterName, imports); } + addJsonSchemaForBodyRequestInCaseItsNotPresent(codegenParameter, body); // set the parameter's example value diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java index 4eacde57abc..f3498f212fb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/IJsonSchemaValidationProperties.java @@ -1,5 +1,6 @@ package org.openapitools.codegen; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -8,6 +9,8 @@ import java.util.Set; import java.util.stream.Stream; import io.swagger.v3.oas.models.media.Schema; +import org.openapitools.codegen.meta.FeatureSet; +import org.openapitools.codegen.meta.features.SchemaSupportFeature; import org.openapitools.codegen.utils.ModelUtils; public interface IJsonSchemaValidationProperties { @@ -261,32 +264,79 @@ public interface IJsonSchemaValidationProperties { /** * Recursively collect all necessary imports to include so that the type may be resolved. * - * @param includeContainerTypes whether or not to include the container types in the returned imports. + * @param importContainerType whether or not to include the container types in the returned imports. + * @param importBaseType whether or not to include the base types in the returned imports. + * @param featureSet the generator feature set, used to determine if composed schemas should be added * @return all of the imports */ - default Set getImports(boolean includeContainerTypes) { + default Set getImports(boolean importContainerType, boolean importBaseType, FeatureSet featureSet) { Set imports = new HashSet<>(); if (this.getComposedSchemas() != null) { - CodegenComposedSchemas composed = (CodegenComposedSchemas) this.getComposedSchemas(); - List allOfs = composed.getAllOf() == null ? Collections.emptyList() : composed.getAllOf(); - List oneOfs = composed.getOneOf() == null ? Collections.emptyList() : composed.getOneOf(); - Stream innerTypes = Stream.concat(allOfs.stream(), oneOfs.stream()); - innerTypes.flatMap(cp -> cp.getImports(includeContainerTypes).stream()).forEach(s -> imports.add(s)); - } else if (includeContainerTypes || !(this.getIsArray() || this.getIsMap())) { - // this is our base case, add imports for referenced schemas - // this can't be broken out as a separate if block because Typescript only generates union types as A | B - // and would need to handle this differently - imports.add(this.getComplexType()); - imports.add(this.getBaseType()); + CodegenComposedSchemas composed = this.getComposedSchemas(); + List allOfs = Collections.emptyList(); + List oneOfs = Collections.emptyList(); + List anyOfs = Collections.emptyList(); + List nots = Collections.emptyList(); + if (composed.getAllOf() != null && featureSet.getSchemaSupportFeatures().contains(SchemaSupportFeature.allOf)) { + allOfs = composed.getAllOf(); + } + if (composed.getOneOf() != null && featureSet.getSchemaSupportFeatures().contains(SchemaSupportFeature.oneOf)) { + oneOfs = composed.getOneOf(); + } + if (composed.getAnyOf() != null && featureSet.getSchemaSupportFeatures().contains(SchemaSupportFeature.anyOf)) { + anyOfs = composed.getAnyOf(); + } + if (composed.getNot() != null && featureSet.getSchemaSupportFeatures().contains(SchemaSupportFeature.not)) { + nots = Arrays.asList(composed.getNot()); + } + Stream innerTypes = Stream.of( + allOfs.stream(), anyOfs.stream(), oneOfs.stream(), nots.stream()) + .flatMap(i -> i); + innerTypes.flatMap(cp -> cp.getImports(importContainerType, importBaseType, featureSet).stream()).forEach(s -> imports.add(s)); } - if (this.getItems() !=null && this.getIsArray()) { - imports.addAll(this.getItems().getImports(includeContainerTypes)); + // items can exist for AnyType and type array + if (this.getItems() != null && this.getIsArray()) { + imports.addAll(this.getItems().getImports(importContainerType, importBaseType, featureSet)); } + // additionalProperties can exist for AnyType and type object if (this.getAdditionalProperties() != null) { - imports.addAll(this.getAdditionalProperties().getImports(includeContainerTypes)); + imports.addAll(this.getAdditionalProperties().getImports(importContainerType, importBaseType, featureSet)); } + // vars can exist for AnyType and type object if (this.getVars() != null && !this.getVars().isEmpty()) { - this.getVars().stream().flatMap(v -> v.getImports(includeContainerTypes).stream()).forEach(s -> imports.add(s)); + this.getVars().stream().flatMap(v -> v.getImports(importContainerType, importBaseType, featureSet).stream()).forEach(s -> imports.add(s)); + } + if (this.getIsArray() || this.getIsMap()) { + if (importContainerType) { + /* + use-case for this complexType block: + DefaultCodegenTest.objectQueryParamIdentifyAsObject + DefaultCodegenTest.mapParamImportInnerObject + */ + String complexType = this.getComplexType(); + if (complexType != null) { + imports.add(complexType); + } + /* + use-case: + Adding List/Map etc, Java uses this + */ + String baseType = this.getBaseType(); + if (importBaseType && baseType != null) { + imports.add(baseType); + } + } + } else { + // referenced or inline schemas + String complexType = this.getComplexType(); + if (complexType != null) { + imports.add(complexType); + } + String baseType = this.getBaseType(); + if (importBaseType && baseType != null) { + imports.add(baseType); + } + return imports; } return imports; } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java index c1b7ac66d37..804cc735a0b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonExperimentalClientCodegen.java @@ -105,10 +105,11 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { // for apis.tags tag api definition private Map tagEnumToApiClassname = new LinkedHashMap<>(); - public PythonExperimentalClientCodegen() { super(); loadDeepObjectIntoItems = false; + importBaseType = false; + addSchemaImportsFromV3SpecLocations = true; modifyFeatureSet(features -> features .includeSchemaSupportFeatures( @@ -321,10 +322,11 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { } if (generateSourceCodeOnly) { - // tests in /test + // tests in test testFolder = packagePath() + File.separatorChar + testFolder; - // api/model docs in /docs + // api docs in /docs/apis/tags/ apiDocPath = packagePath() + File.separatorChar + apiDocPath; + // model docs in /docs/models/ modelDocPath = packagePath() + File.separatorChar + modelDocPath; } // make api and model doc path available in templates @@ -866,7 +868,6 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { OperationMap val = objs.getOperations(); List operations = val.getOperation(); - List> imports = objs.getImports(); for (CodegenOperation operation : operations) { if (operation.imports.size() == 0) { continue; @@ -901,12 +902,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen { boolean anyModelContainsTestCases = false; Map allDefinitions = ModelUtils.getSchemas(this.openAPI); for (String schemaName : allDefinitions.keySet()) { - Schema refSchema = new Schema().$ref("#/components/schemas/" + schemaName); - Schema unaliasedSchema = unaliasSchema(refSchema); String modelName = toModelName(schemaName); - if (unaliasedSchema.get$ref() == null) { - continue; - } ModelsMap objModel = objs.get(modelName); if (objModel == null) { // to avoid form parameter's models that are not generated (skipFormModel=true) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java index 4352df6a098..a076cf99dd6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java @@ -969,7 +969,7 @@ public class SpringCodegen extends AbstractJavaCodegen parentVar.isInherited = true; LOGGER.info("adding parent variable {}", property.name); codegenModel.parentVars.add(parentVar); - Set imports = parentVar.getImports(true).stream().filter(Objects::nonNull).collect(Collectors.toSet()); + Set imports = parentVar.getImports(true, this.importBaseType, generatorMetadata.getFeatureSet()).stream().filter(Objects::nonNull).collect(Collectors.toSet()); for (String imp: imports) { // Avoid dupes if (!codegenModel.getImports().contains(imp)) { diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java index 86c85a02dc1..1fa2e72554c 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJAXRSSpecServerCodegenTest.java @@ -380,9 +380,8 @@ public class JavaJAXRSSpecServerCodegenTest extends JavaJaxrsBaseTest { String outputPath = output.getAbsolutePath().replace('\\', '/'); OpenAPI openAPI = new OpenAPIParser() - .readLocation("src/test/resources/3_0/arrayParameter.yaml", null, new ParseOptions()).getOpenAPI(); + .readLocation("src/test/resources/3_0/setParameter.yaml", null, new ParseOptions()).getOpenAPI(); - openAPI.getComponents().getParameters().get("operationsQueryParam").setSchema(new ArraySchema().uniqueItems(true)); codegen.setOutputDir(output.getAbsolutePath()); codegen.additionalProperties().put(CXFServerFeatures.LOAD_TEST_DATA_FROM_FILE, "true"); diff --git a/modules/openapi-generator/src/test/resources/3_0/setParameter.yaml b/modules/openapi-generator/src/test/resources/3_0/setParameter.yaml new file mode 100644 index 00000000000..2fc2dd5dc0e --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/setParameter.yaml @@ -0,0 +1,22 @@ +openapi: 3.0.0 +paths: + /examples: + get: + tags: + - Examples + summary: Get a list of transactions + operationId: getFilteredTransactions + parameters: + - $ref: '#/components/parameters/operationsQueryParam' +components: + parameters: + operationsQueryParam: + name: operations + description: Operations list + in: query + required: false + schema: + type: array + items: + type: string + uniqueItems: true \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml index e0c8d0a1dfe..053751510ff 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/3_0_3_unit_test_spec.yaml @@ -2664,6 +2664,42 @@ paths: - path.post - contentType_json - $ref + /requestBody/postRefInNotRequestBody: + post: + operationId: postRefInNotRequestBody + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RefInNot' + x-schema-test-examples: + $ref: '#/components/x-schema-test-examples/RefInNot' + required: true + responses: + '200': + description: success + tags: + - operation.requestBody + - path.post + - contentType_json + - $ref + /responseBody/postRefInNotResponseBodyForContentTypes: + post: + operationId: postRefInNotResponseBodyForContentTypes + responses: + '200': + description: success + content: + application/json: + schema: + $ref: '#/components/schemas/RefInNot' + x-schema-test-examples: + $ref: '#/components/x-schema-test-examples/RefInNot' + tags: + - response.content.contentType.schema + - path.post + - contentType_json + - $ref /requestBody/postRequiredValidationRequestBody: post: operationId: postRequiredValidationRequestBody @@ -3450,6 +3486,9 @@ components: RefInAnyof: anyOf: - $ref: '#/components/schemas/PropertyNamedRefThatIsNotAReference' + RefInNot: + not: + $ref: '#/components/schemas/PropertyNamedRefThatIsNotAReference' RequiredValidation: properties: foo: {} @@ -4741,6 +4780,17 @@ components: data: $ref: 2 valid: false + RefInNot: + PropertyNamedRefInvalid: + description: property named $ref invalid + data: + $ref: a + valid: false + PropertyNamedRefValid: + description: property named $ref valid + data: + $ref: 2 + valid: true RequiredValidation: PresentRequiredPropertyIsValid: description: present required property is valid diff --git a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py index aef9d513fc3..51c4b0ee0e3 100644 --- a/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py +++ b/modules/openapi-generator/src/test/resources/3_0/unit_test_spec/spec_writer.py @@ -101,7 +101,6 @@ class ExclusionReason: component_ref_component_bug = 'A component refing another component does not work, issue at https://github.com/OpenAPITools/openapi-generator/issues/12730' not_running_the_localhost_server = 'the openapo-generator is not running the localhost server needed to serve remoteRef files' v303_requires_that_the_default_value_is_an_allowed_type = 'v3.0.3 requires that the default value is an allowed type per the schema' - not_ref_import_missing = 'this test fails because of this open issue https://github.com/OpenAPITools/openapi-generator/issues/12756' json_schema_test_draft = 'draft6' openapi_additions = 'openapi_additions' @@ -179,7 +178,6 @@ FILEPATH_TO_EXCLUDED_CASE_AND_REASON = { 'property refs adjacent property': ExclusionReason.ref_to_adjacent_property_bug, 'property refs containing component schema': ExclusionReason.swagger_parser_anytype_bug, 'component refs another component': ExclusionReason.component_ref_component_bug, - 'ref in not': ExclusionReason.not_ref_import_missing }, (json_schema_test_draft, 'refRemote.json'): { 'base URI change - change folder': ExclusionReason.v303_does_not_support_id, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES index a2411594672..ccb99381aa8 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/.openapi-generator/FILES @@ -101,6 +101,7 @@ docs/models/RefInAdditionalproperties.md docs/models/RefInAllof.md docs/models/RefInAnyof.md docs/models/RefInItems.md +docs/models/RefInNot.md docs/models/RefInOneof.md docs/models/RefInProperty.md docs/models/RequiredDefaultValidation.md @@ -193,6 +194,7 @@ test/test_models/test_ref_in_additionalproperties.py test/test_models/test_ref_in_allof.py test/test_models/test_ref_in_anyof.py test/test_models/test_ref_in_items.py +test/test_models/test_ref_in_not.py test/test_models/test_ref_in_oneof.py test/test_models/test_ref_in_property.py test/test_models/test_required_default_validation.py @@ -313,6 +315,7 @@ unit_test_api/model/ref_in_additionalproperties.py unit_test_api/model/ref_in_allof.py unit_test_api/model/ref_in_anyof.py unit_test_api/model/ref_in_items.py +unit_test_api/model/ref_in_not.py unit_test_api/model/ref_in_oneof.py unit_test_api/model/ref_in_property.py unit_test_api/model/required_default_validation.py diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md index 92b8b0d354d..ffb5fbbea5c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/README.md @@ -158,6 +158,8 @@ Class | Method | HTTP request | Description *RefApi* | [**post_ref_in_anyof_response_body_for_content_types**](docs/apis/tags/RefApi.md#post_ref_in_anyof_response_body_for_content_types) | **post** /responseBody/postRefInAnyofResponseBodyForContentTypes | *RefApi* | [**post_ref_in_items_request_body**](docs/apis/tags/RefApi.md#post_ref_in_items_request_body) | **post** /requestBody/postRefInItemsRequestBody | *RefApi* | [**post_ref_in_items_response_body_for_content_types**](docs/apis/tags/RefApi.md#post_ref_in_items_response_body_for_content_types) | **post** /responseBody/postRefInItemsResponseBodyForContentTypes | +*RefApi* | [**post_ref_in_not_request_body**](docs/apis/tags/RefApi.md#post_ref_in_not_request_body) | **post** /requestBody/postRefInNotRequestBody | +*RefApi* | [**post_ref_in_not_response_body_for_content_types**](docs/apis/tags/RefApi.md#post_ref_in_not_response_body_for_content_types) | **post** /responseBody/postRefInNotResponseBodyForContentTypes | *RefApi* | [**post_ref_in_oneof_request_body**](docs/apis/tags/RefApi.md#post_ref_in_oneof_request_body) | **post** /requestBody/postRefInOneofRequestBody | *RefApi* | [**post_ref_in_oneof_response_body_for_content_types**](docs/apis/tags/RefApi.md#post_ref_in_oneof_response_body_for_content_types) | **post** /responseBody/postRefInOneofResponseBodyForContentTypes | *RefApi* | [**post_ref_in_property_request_body**](docs/apis/tags/RefApi.md#post_ref_in_property_request_body) | **post** /requestBody/postRefInPropertyRequestBody | @@ -342,6 +344,8 @@ Class | Method | HTTP request | Description *ContentTypeJsonApi* | [**post_ref_in_anyof_response_body_for_content_types**](docs/apis/tags/ContentTypeJsonApi.md#post_ref_in_anyof_response_body_for_content_types) | **post** /responseBody/postRefInAnyofResponseBodyForContentTypes | *ContentTypeJsonApi* | [**post_ref_in_items_request_body**](docs/apis/tags/ContentTypeJsonApi.md#post_ref_in_items_request_body) | **post** /requestBody/postRefInItemsRequestBody | *ContentTypeJsonApi* | [**post_ref_in_items_response_body_for_content_types**](docs/apis/tags/ContentTypeJsonApi.md#post_ref_in_items_response_body_for_content_types) | **post** /responseBody/postRefInItemsResponseBodyForContentTypes | +*ContentTypeJsonApi* | [**post_ref_in_not_request_body**](docs/apis/tags/ContentTypeJsonApi.md#post_ref_in_not_request_body) | **post** /requestBody/postRefInNotRequestBody | +*ContentTypeJsonApi* | [**post_ref_in_not_response_body_for_content_types**](docs/apis/tags/ContentTypeJsonApi.md#post_ref_in_not_response_body_for_content_types) | **post** /responseBody/postRefInNotResponseBodyForContentTypes | *ContentTypeJsonApi* | [**post_ref_in_oneof_request_body**](docs/apis/tags/ContentTypeJsonApi.md#post_ref_in_oneof_request_body) | **post** /requestBody/postRefInOneofRequestBody | *ContentTypeJsonApi* | [**post_ref_in_oneof_response_body_for_content_types**](docs/apis/tags/ContentTypeJsonApi.md#post_ref_in_oneof_response_body_for_content_types) | **post** /responseBody/postRefInOneofResponseBodyForContentTypes | *ContentTypeJsonApi* | [**post_ref_in_property_request_body**](docs/apis/tags/ContentTypeJsonApi.md#post_ref_in_property_request_body) | **post** /requestBody/postRefInPropertyRequestBody | @@ -530,6 +534,7 @@ Class | Method | HTTP request | Description *OperationRequestBodyApi* | [**post_ref_in_allof_request_body**](docs/apis/tags/OperationRequestBodyApi.md#post_ref_in_allof_request_body) | **post** /requestBody/postRefInAllofRequestBody | *OperationRequestBodyApi* | [**post_ref_in_anyof_request_body**](docs/apis/tags/OperationRequestBodyApi.md#post_ref_in_anyof_request_body) | **post** /requestBody/postRefInAnyofRequestBody | *OperationRequestBodyApi* | [**post_ref_in_items_request_body**](docs/apis/tags/OperationRequestBodyApi.md#post_ref_in_items_request_body) | **post** /requestBody/postRefInItemsRequestBody | +*OperationRequestBodyApi* | [**post_ref_in_not_request_body**](docs/apis/tags/OperationRequestBodyApi.md#post_ref_in_not_request_body) | **post** /requestBody/postRefInNotRequestBody | *OperationRequestBodyApi* | [**post_ref_in_oneof_request_body**](docs/apis/tags/OperationRequestBodyApi.md#post_ref_in_oneof_request_body) | **post** /requestBody/postRefInOneofRequestBody | *OperationRequestBodyApi* | [**post_ref_in_property_request_body**](docs/apis/tags/OperationRequestBodyApi.md#post_ref_in_property_request_body) | **post** /requestBody/postRefInPropertyRequestBody | *OperationRequestBodyApi* | [**post_required_default_validation_request_body**](docs/apis/tags/OperationRequestBodyApi.md#post_required_default_validation_request_body) | **post** /requestBody/postRequiredDefaultValidationRequestBody | @@ -688,6 +693,8 @@ Class | Method | HTTP request | Description *PathPostApi* | [**post_ref_in_anyof_response_body_for_content_types**](docs/apis/tags/PathPostApi.md#post_ref_in_anyof_response_body_for_content_types) | **post** /responseBody/postRefInAnyofResponseBodyForContentTypes | *PathPostApi* | [**post_ref_in_items_request_body**](docs/apis/tags/PathPostApi.md#post_ref_in_items_request_body) | **post** /requestBody/postRefInItemsRequestBody | *PathPostApi* | [**post_ref_in_items_response_body_for_content_types**](docs/apis/tags/PathPostApi.md#post_ref_in_items_response_body_for_content_types) | **post** /responseBody/postRefInItemsResponseBodyForContentTypes | +*PathPostApi* | [**post_ref_in_not_request_body**](docs/apis/tags/PathPostApi.md#post_ref_in_not_request_body) | **post** /requestBody/postRefInNotRequestBody | +*PathPostApi* | [**post_ref_in_not_response_body_for_content_types**](docs/apis/tags/PathPostApi.md#post_ref_in_not_response_body_for_content_types) | **post** /responseBody/postRefInNotResponseBodyForContentTypes | *PathPostApi* | [**post_ref_in_oneof_request_body**](docs/apis/tags/PathPostApi.md#post_ref_in_oneof_request_body) | **post** /requestBody/postRefInOneofRequestBody | *PathPostApi* | [**post_ref_in_oneof_response_body_for_content_types**](docs/apis/tags/PathPostApi.md#post_ref_in_oneof_response_body_for_content_types) | **post** /responseBody/postRefInOneofResponseBodyForContentTypes | *PathPostApi* | [**post_ref_in_property_request_body**](docs/apis/tags/PathPostApi.md#post_ref_in_property_request_body) | **post** /requestBody/postRefInPropertyRequestBody | @@ -804,6 +811,7 @@ Class | Method | HTTP request | Description *ResponseContentContentTypeSchemaApi* | [**post_ref_in_allof_response_body_for_content_types**](docs/apis/tags/ResponseContentContentTypeSchemaApi.md#post_ref_in_allof_response_body_for_content_types) | **post** /responseBody/postRefInAllofResponseBodyForContentTypes | *ResponseContentContentTypeSchemaApi* | [**post_ref_in_anyof_response_body_for_content_types**](docs/apis/tags/ResponseContentContentTypeSchemaApi.md#post_ref_in_anyof_response_body_for_content_types) | **post** /responseBody/postRefInAnyofResponseBodyForContentTypes | *ResponseContentContentTypeSchemaApi* | [**post_ref_in_items_response_body_for_content_types**](docs/apis/tags/ResponseContentContentTypeSchemaApi.md#post_ref_in_items_response_body_for_content_types) | **post** /responseBody/postRefInItemsResponseBodyForContentTypes | +*ResponseContentContentTypeSchemaApi* | [**post_ref_in_not_response_body_for_content_types**](docs/apis/tags/ResponseContentContentTypeSchemaApi.md#post_ref_in_not_response_body_for_content_types) | **post** /responseBody/postRefInNotResponseBodyForContentTypes | *ResponseContentContentTypeSchemaApi* | [**post_ref_in_oneof_response_body_for_content_types**](docs/apis/tags/ResponseContentContentTypeSchemaApi.md#post_ref_in_oneof_response_body_for_content_types) | **post** /responseBody/postRefInOneofResponseBodyForContentTypes | *ResponseContentContentTypeSchemaApi* | [**post_ref_in_property_response_body_for_content_types**](docs/apis/tags/ResponseContentContentTypeSchemaApi.md#post_ref_in_property_response_body_for_content_types) | **post** /responseBody/postRefInPropertyResponseBodyForContentTypes | *ResponseContentContentTypeSchemaApi* | [**post_required_default_validation_response_body_for_content_types**](docs/apis/tags/ResponseContentContentTypeSchemaApi.md#post_required_default_validation_response_body_for_content_types) | **post** /responseBody/postRequiredDefaultValidationResponseBodyForContentTypes | @@ -910,6 +918,7 @@ Class | Method | HTTP request | Description - [RefInAllof](docs/models/RefInAllof.md) - [RefInAnyof](docs/models/RefInAnyof.md) - [RefInItems](docs/models/RefInItems.md) + - [RefInNot](docs/models/RefInNot.md) - [RefInOneof](docs/models/RefInOneof.md) - [RefInProperty](docs/models/RefInProperty.md) - [RequiredDefaultValidation](docs/models/RequiredDefaultValidation.md) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/ContentTypeJsonApi.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/ContentTypeJsonApi.md index a4a9dddfd41..72052ca2e67 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/ContentTypeJsonApi.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/ContentTypeJsonApi.md @@ -149,6 +149,8 @@ Method | HTTP request | Description [**post_ref_in_anyof_response_body_for_content_types**](#post_ref_in_anyof_response_body_for_content_types) | **post** /responseBody/postRefInAnyofResponseBodyForContentTypes | [**post_ref_in_items_request_body**](#post_ref_in_items_request_body) | **post** /requestBody/postRefInItemsRequestBody | [**post_ref_in_items_response_body_for_content_types**](#post_ref_in_items_response_body_for_content_types) | **post** /responseBody/postRefInItemsResponseBodyForContentTypes | +[**post_ref_in_not_request_body**](#post_ref_in_not_request_body) | **post** /requestBody/postRefInNotRequestBody | +[**post_ref_in_not_response_body_for_content_types**](#post_ref_in_not_response_body_for_content_types) | **post** /responseBody/postRefInNotResponseBodyForContentTypes | [**post_ref_in_oneof_request_body**](#post_ref_in_oneof_request_body) | **post** /requestBody/postRefInOneofRequestBody | [**post_ref_in_oneof_response_body_for_content_types**](#post_ref_in_oneof_response_body_for_content_types) | **post** /responseBody/postRefInOneofResponseBodyForContentTypes | [**post_ref_in_property_request_body**](#post_ref_in_property_request_body) | **post** /requestBody/postRefInPropertyRequestBody | @@ -10056,6 +10058,145 @@ 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) +# **post_ref_in_not_request_body** + +> post_ref_in_not_request_body(body) + + + +### Example + +```python +import unit_test_api +from unit_test_api.apis.tags import content_type_json_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from pprint import pprint +# Defining the host is optional and defaults to https://someserver.com/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = unit_test_api.Configuration( + host = "https://someserver.com/v1" +) + +# Enter a context with an instance of the API client +with unit_test_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = content_type_json_api.ContentTypeJsonApi(api_client) + + # example passing only required values which don't have defaults set + body = None + try: + api_response = api_instance.post_ref_in_not_request_body( + body=body, + ) + except unit_test_api.ApiException as e: + print("Exception when calling ContentTypeJsonApi->post_ref_in_not_request_body: %s\n" % e) +``` +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +body | typing.Union[SchemaForRequestBodyApplicationJson] | required | +content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body +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 + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +### Return Types, Responses + +Code | Class | Description +------------- | ------------- | ------------- +n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned +200 | ApiResponseFor200 | success + +#### 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 + +[[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) + +# **post_ref_in_not_response_body_for_content_types** + +> bool, date, datetime, dict, float, int, list, str, none_type post_ref_in_not_response_body_for_content_types() + + + +### Example + +```python +import unit_test_api +from unit_test_api.apis.tags import content_type_json_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from pprint import pprint +# Defining the host is optional and defaults to https://someserver.com/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = unit_test_api.Configuration( + host = "https://someserver.com/v1" +) + +# Enter a context with an instance of the API client +with unit_test_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = content_type_json_api.ContentTypeJsonApi(api_client) + + # example, this endpoint has no required or optional parameters + try: + api_response = api_instance.post_ref_in_not_response_body_for_content_types() + pprint(api_response) + except unit_test_api.ApiException as e: + print("Exception when calling ContentTypeJsonApi->post_ref_in_not_response_body_for_content_types: %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 | success + +#### ApiResponseFor200 +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +response | urllib3.HTTPResponse | Raw response | +body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | | +headers | Unset | headers were not defined | + +#### SchemaFor200ResponseBodyApplicationJson + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + + +**bool, date, datetime, dict, float, int, list, str, none_type** + +### 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) + # **post_ref_in_oneof_request_body** > post_ref_in_oneof_request_body(ref_in_oneof) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/OperationRequestBodyApi.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/OperationRequestBodyApi.md index 1609be19286..222140ad79f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/OperationRequestBodyApi.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/OperationRequestBodyApi.md @@ -77,6 +77,7 @@ Method | HTTP request | Description [**post_ref_in_allof_request_body**](#post_ref_in_allof_request_body) | **post** /requestBody/postRefInAllofRequestBody | [**post_ref_in_anyof_request_body**](#post_ref_in_anyof_request_body) | **post** /requestBody/postRefInAnyofRequestBody | [**post_ref_in_items_request_body**](#post_ref_in_items_request_body) | **post** /requestBody/postRefInItemsRequestBody | +[**post_ref_in_not_request_body**](#post_ref_in_not_request_body) | **post** /requestBody/postRefInNotRequestBody | [**post_ref_in_oneof_request_body**](#post_ref_in_oneof_request_body) | **post** /requestBody/postRefInOneofRequestBody | [**post_ref_in_property_request_body**](#post_ref_in_property_request_body) | **post** /requestBody/postRefInPropertyRequestBody | [**post_required_default_validation_request_body**](#post_required_default_validation_request_body) | **post** /requestBody/postRequiredDefaultValidationRequestBody | @@ -5430,6 +5431,81 @@ body | Unset | body was not defined | headers | Unset | headers were not defined | +void (empty response body) + +### 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) + +# **post_ref_in_not_request_body** + +> post_ref_in_not_request_body(body) + + + +### Example + +```python +import unit_test_api +from unit_test_api.apis.tags import operation_request_body_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from pprint import pprint +# Defining the host is optional and defaults to https://someserver.com/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = unit_test_api.Configuration( + host = "https://someserver.com/v1" +) + +# Enter a context with an instance of the API client +with unit_test_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = operation_request_body_api.OperationRequestBodyApi(api_client) + + # example passing only required values which don't have defaults set + body = None + try: + api_response = api_instance.post_ref_in_not_request_body( + body=body, + ) + except unit_test_api.ApiException as e: + print("Exception when calling OperationRequestBodyApi->post_ref_in_not_request_body: %s\n" % e) +``` +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +body | typing.Union[SchemaForRequestBodyApplicationJson] | required | +content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body +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 + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +### Return Types, Responses + +Code | Class | Description +------------- | ------------- | ------------- +n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned +200 | ApiResponseFor200 | success + +#### 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 diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/PathPostApi.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/PathPostApi.md index 5936b9a0a98..afc26cec86c 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/PathPostApi.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/PathPostApi.md @@ -149,6 +149,8 @@ Method | HTTP request | Description [**post_ref_in_anyof_response_body_for_content_types**](#post_ref_in_anyof_response_body_for_content_types) | **post** /responseBody/postRefInAnyofResponseBodyForContentTypes | [**post_ref_in_items_request_body**](#post_ref_in_items_request_body) | **post** /requestBody/postRefInItemsRequestBody | [**post_ref_in_items_response_body_for_content_types**](#post_ref_in_items_response_body_for_content_types) | **post** /responseBody/postRefInItemsResponseBodyForContentTypes | +[**post_ref_in_not_request_body**](#post_ref_in_not_request_body) | **post** /requestBody/postRefInNotRequestBody | +[**post_ref_in_not_response_body_for_content_types**](#post_ref_in_not_response_body_for_content_types) | **post** /responseBody/postRefInNotResponseBodyForContentTypes | [**post_ref_in_oneof_request_body**](#post_ref_in_oneof_request_body) | **post** /requestBody/postRefInOneofRequestBody | [**post_ref_in_oneof_response_body_for_content_types**](#post_ref_in_oneof_response_body_for_content_types) | **post** /responseBody/postRefInOneofResponseBodyForContentTypes | [**post_ref_in_property_request_body**](#post_ref_in_property_request_body) | **post** /requestBody/postRefInPropertyRequestBody | @@ -10056,6 +10058,145 @@ 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) +# **post_ref_in_not_request_body** + +> post_ref_in_not_request_body(body) + + + +### Example + +```python +import unit_test_api +from unit_test_api.apis.tags import path_post_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from pprint import pprint +# Defining the host is optional and defaults to https://someserver.com/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = unit_test_api.Configuration( + host = "https://someserver.com/v1" +) + +# Enter a context with an instance of the API client +with unit_test_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = path_post_api.PathPostApi(api_client) + + # example passing only required values which don't have defaults set + body = None + try: + api_response = api_instance.post_ref_in_not_request_body( + body=body, + ) + except unit_test_api.ApiException as e: + print("Exception when calling PathPostApi->post_ref_in_not_request_body: %s\n" % e) +``` +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +body | typing.Union[SchemaForRequestBodyApplicationJson] | required | +content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body +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 + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +### Return Types, Responses + +Code | Class | Description +------------- | ------------- | ------------- +n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned +200 | ApiResponseFor200 | success + +#### 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 + +[[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) + +# **post_ref_in_not_response_body_for_content_types** + +> bool, date, datetime, dict, float, int, list, str, none_type post_ref_in_not_response_body_for_content_types() + + + +### Example + +```python +import unit_test_api +from unit_test_api.apis.tags import path_post_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from pprint import pprint +# Defining the host is optional and defaults to https://someserver.com/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = unit_test_api.Configuration( + host = "https://someserver.com/v1" +) + +# Enter a context with an instance of the API client +with unit_test_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = path_post_api.PathPostApi(api_client) + + # example, this endpoint has no required or optional parameters + try: + api_response = api_instance.post_ref_in_not_response_body_for_content_types() + pprint(api_response) + except unit_test_api.ApiException as e: + print("Exception when calling PathPostApi->post_ref_in_not_response_body_for_content_types: %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 | success + +#### ApiResponseFor200 +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +response | urllib3.HTTPResponse | Raw response | +body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | | +headers | Unset | headers were not defined | + +#### SchemaFor200ResponseBodyApplicationJson + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + + +**bool, date, datetime, dict, float, int, list, str, none_type** + +### 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) + # **post_ref_in_oneof_request_body** > post_ref_in_oneof_request_body(ref_in_oneof) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/RefApi.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/RefApi.md index 54e2c099236..8599080d6c0 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/RefApi.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/RefApi.md @@ -15,6 +15,8 @@ Method | HTTP request | Description [**post_ref_in_anyof_response_body_for_content_types**](#post_ref_in_anyof_response_body_for_content_types) | **post** /responseBody/postRefInAnyofResponseBodyForContentTypes | [**post_ref_in_items_request_body**](#post_ref_in_items_request_body) | **post** /requestBody/postRefInItemsRequestBody | [**post_ref_in_items_response_body_for_content_types**](#post_ref_in_items_response_body_for_content_types) | **post** /responseBody/postRefInItemsResponseBodyForContentTypes | +[**post_ref_in_not_request_body**](#post_ref_in_not_request_body) | **post** /requestBody/postRefInNotRequestBody | +[**post_ref_in_not_response_body_for_content_types**](#post_ref_in_not_response_body_for_content_types) | **post** /responseBody/postRefInNotResponseBodyForContentTypes | [**post_ref_in_oneof_request_body**](#post_ref_in_oneof_request_body) | **post** /requestBody/postRefInOneofRequestBody | [**post_ref_in_oneof_response_body_for_content_types**](#post_ref_in_oneof_response_body_for_content_types) | **post** /responseBody/postRefInOneofResponseBodyForContentTypes | [**post_ref_in_property_request_body**](#post_ref_in_property_request_body) | **post** /requestBody/postRefInPropertyRequestBody | @@ -709,6 +711,145 @@ 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) +# **post_ref_in_not_request_body** + +> post_ref_in_not_request_body(body) + + + +### Example + +```python +import unit_test_api +from unit_test_api.apis.tags import ref_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from pprint import pprint +# Defining the host is optional and defaults to https://someserver.com/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = unit_test_api.Configuration( + host = "https://someserver.com/v1" +) + +# Enter a context with an instance of the API client +with unit_test_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = ref_api.RefApi(api_client) + + # example passing only required values which don't have defaults set + body = None + try: + api_response = api_instance.post_ref_in_not_request_body( + body=body, + ) + except unit_test_api.ApiException as e: + print("Exception when calling RefApi->post_ref_in_not_request_body: %s\n" % e) +``` +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +body | typing.Union[SchemaForRequestBodyApplicationJson] | required | +content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body +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 + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +### Return Types, Responses + +Code | Class | Description +------------- | ------------- | ------------- +n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned +200 | ApiResponseFor200 | success + +#### 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 + +[[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) + +# **post_ref_in_not_response_body_for_content_types** + +> bool, date, datetime, dict, float, int, list, str, none_type post_ref_in_not_response_body_for_content_types() + + + +### Example + +```python +import unit_test_api +from unit_test_api.apis.tags import ref_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from pprint import pprint +# Defining the host is optional and defaults to https://someserver.com/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = unit_test_api.Configuration( + host = "https://someserver.com/v1" +) + +# Enter a context with an instance of the API client +with unit_test_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = ref_api.RefApi(api_client) + + # example, this endpoint has no required or optional parameters + try: + api_response = api_instance.post_ref_in_not_response_body_for_content_types() + pprint(api_response) + except unit_test_api.ApiException as e: + print("Exception when calling RefApi->post_ref_in_not_response_body_for_content_types: %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 | success + +#### ApiResponseFor200 +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +response | urllib3.HTTPResponse | Raw response | +body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | | +headers | Unset | headers were not defined | + +#### SchemaFor200ResponseBodyApplicationJson + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + + +**bool, date, datetime, dict, float, int, list, str, none_type** + +### 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) + # **post_ref_in_oneof_request_body** > post_ref_in_oneof_request_body(ref_in_oneof) diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/ResponseContentContentTypeSchemaApi.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/ResponseContentContentTypeSchemaApi.md index d7d4128a64c..4c6946eb07f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/ResponseContentContentTypeSchemaApi.md +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/apis/tags/ResponseContentContentTypeSchemaApi.md @@ -77,6 +77,7 @@ Method | HTTP request | Description [**post_ref_in_allof_response_body_for_content_types**](#post_ref_in_allof_response_body_for_content_types) | **post** /responseBody/postRefInAllofResponseBodyForContentTypes | [**post_ref_in_anyof_response_body_for_content_types**](#post_ref_in_anyof_response_body_for_content_types) | **post** /responseBody/postRefInAnyofResponseBodyForContentTypes | [**post_ref_in_items_response_body_for_content_types**](#post_ref_in_items_response_body_for_content_types) | **post** /responseBody/postRefInItemsResponseBodyForContentTypes | +[**post_ref_in_not_response_body_for_content_types**](#post_ref_in_not_response_body_for_content_types) | **post** /responseBody/postRefInNotResponseBodyForContentTypes | [**post_ref_in_oneof_response_body_for_content_types**](#post_ref_in_oneof_response_body_for_content_types) | **post** /responseBody/postRefInOneofResponseBodyForContentTypes | [**post_ref_in_property_response_body_for_content_types**](#post_ref_in_property_response_body_for_content_types) | **post** /responseBody/postRefInPropertyResponseBodyForContentTypes | [**post_required_default_validation_response_body_for_content_types**](#post_required_default_validation_response_body_for_content_types) | **post** /responseBody/postRequiredDefaultValidationResponseBodyForContentTypes | @@ -4624,6 +4625,70 @@ 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) +# **post_ref_in_not_response_body_for_content_types** + +> bool, date, datetime, dict, float, int, list, str, none_type post_ref_in_not_response_body_for_content_types() + + + +### Example + +```python +import unit_test_api +from unit_test_api.apis.tags import response_content_content_type_schema_api +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference +from pprint import pprint +# Defining the host is optional and defaults to https://someserver.com/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = unit_test_api.Configuration( + host = "https://someserver.com/v1" +) + +# Enter a context with an instance of the API client +with unit_test_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = response_content_content_type_schema_api.ResponseContentContentTypeSchemaApi(api_client) + + # example, this endpoint has no required or optional parameters + try: + api_response = api_instance.post_ref_in_not_response_body_for_content_types() + pprint(api_response) + except unit_test_api.ApiException as e: + print("Exception when calling ResponseContentContentTypeSchemaApi->post_ref_in_not_response_body_for_content_types: %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 | success + +#### ApiResponseFor200 +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +response | urllib3.HTTPResponse | Raw response | +body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | | +headers | Unset | headers were not defined | + +#### SchemaFor200ResponseBodyApplicationJson + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + + +**bool, date, datetime, dict, float, int, list, str, none_type** + +### 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) + # **post_ref_in_oneof_response_body_for_content_types** > RefInOneof post_ref_in_oneof_response_body_for_content_types() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/RefInNot.md b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/RefInNot.md new file mode 100644 index 00000000000..8c7552bd04f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/docs/models/RefInNot.md @@ -0,0 +1,9 @@ +# unit_test_api.model.ref_in_not.RefInNot + +#### Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_not.py new file mode 100644 index 00000000000..53ce63342a8 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_models/test_ref_in_not.py @@ -0,0 +1,46 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import unittest + +import unit_test_api +from unit_test_api.model.ref_in_not import RefInNot +from unit_test_api import configuration + + +class TestRefInNot(unittest.TestCase): + """RefInNot unit test stubs""" + _configuration = configuration.Configuration() + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + RefInNot._from_openapi_data( + { + "$ref": + 2, + }, + _configuration=self._configuration + ) + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + RefInNot._from_openapi_data( + { + "$ref": + "a", + }, + _configuration=self._configuration + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_not_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_not_request_body/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_not_request_body/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_not_request_body/test_post.py new file mode 100644 index 00000000000..9afe491c1b7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_request_body_post_ref_in_not_request_body/test_post.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.request_body_post_ref_in_not_request_body import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestRequestBodyPostRefInNotRequestBody(ApiTestMixin, unittest.TestCase): + """ + RequestBodyPostRefInNotRequestBody unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + response_body = '' + + def test_property_named_ref_valid_passes(self): + content_type = 'application/json' + # property named $ref valid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + 2, + } + ) + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + mock_request.return_value = self.response( + self.json_bytes(self.response_body), + status=self.response_status + ) + api_response = self.api.post( + body=body, + content_type=content_type + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/requestBody/postRefInNotRequestBody', + method='post'.upper(), + body=self.json_bytes(payload), + content_type=content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, schemas.Unset) + + def test_property_named_ref_invalid_fails(self): + content_type = 'application/json' + # property named $ref invalid + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + "a", + } + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + body = post.SchemaForRequestBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + self.api.post(body=body) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_not_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_not_response_body_for_content_types/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_not_response_body_for_content_types/test_post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_not_response_body_for_content_types/test_post.py new file mode 100644 index 00000000000..1280e04e2de --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/test/test_paths/test_response_body_post_ref_in_not_response_body_for_content_types/test_post.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +import unittest +from unittest.mock import patch + +import urllib3 + +import unit_test_api +from unit_test_api.paths.response_body_post_ref_in_not_response_body_for_content_types import post # noqa: E501 +from unit_test_api import configuration, schemas, api_client + +from .. import ApiTestMixin + + +class TestResponseBodyPostRefInNotResponseBodyForContentTypes(ApiTestMixin, unittest.TestCase): + """ + ResponseBodyPostRefInNotResponseBodyForContentTypes unit test stubs + """ + _configuration = configuration.Configuration() + + def setUp(self): + used_api_client = api_client.ApiClient(configuration=self._configuration) + self.api = post.ApiForpost(api_client=used_api_client) # noqa: E501 + + def tearDown(self): + pass + + response_status = 200 + + def test_property_named_ref_valid_passes(self): + # property named $ref valid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + 2, + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + api_response = self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInNotResponseBodyForContentTypes', + method='post'.upper(), + accept_content_type=accept_content_type, + ) + + assert isinstance(api_response.response, urllib3.HTTPResponse) + assert isinstance(api_response.body, post.SchemaFor200ResponseBodyApplicationJson) + deserialized_response_body = post.SchemaFor200ResponseBodyApplicationJson._from_openapi_data( + payload, + _configuration=self._configuration + ) + assert api_response.body == deserialized_response_body + + def test_property_named_ref_invalid_fails(self): + # property named $ref invalid + accept_content_type = 'application/json' + + with patch.object(urllib3.PoolManager, 'request') as mock_request: + payload = ( + { + "$ref": + "a", + } + ) + mock_request.return_value = self.response( + self.json_bytes(payload), + status=self.response_status + ) + with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)): + self.api.post( + accept_content_types=(accept_content_type,) + ) + self.assert_pool_manager_request_called_with( + mock_request, + self._configuration.host + '/responseBody/postRefInNotResponseBodyForContentTypes', + method='post'.upper(), + content_type=None, + accept_content_type=accept_content_type, + ) + + + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/path_to_api.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/path_to_api.py index 77ae7d58a3c..dd7ac51a7a9 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/path_to_api.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/path_to_api.py @@ -147,6 +147,8 @@ from unit_test_api.apis.paths.request_body_post_ref_in_oneof_request_body import from unit_test_api.apis.paths.response_body_post_ref_in_oneof_response_body_for_content_types import ResponseBodyPostRefInOneofResponseBodyForContentTypes from unit_test_api.apis.paths.request_body_post_ref_in_anyof_request_body import RequestBodyPostRefInAnyofRequestBody from unit_test_api.apis.paths.response_body_post_ref_in_anyof_response_body_for_content_types import ResponseBodyPostRefInAnyofResponseBodyForContentTypes +from unit_test_api.apis.paths.request_body_post_ref_in_not_request_body import RequestBodyPostRefInNotRequestBody +from unit_test_api.apis.paths.response_body_post_ref_in_not_response_body_for_content_types import ResponseBodyPostRefInNotResponseBodyForContentTypes from unit_test_api.apis.paths.request_body_post_required_validation_request_body import RequestBodyPostRequiredValidationRequestBody from unit_test_api.apis.paths.response_body_post_required_validation_response_body_for_content_types import ResponseBodyPostRequiredValidationResponseBodyForContentTypes from unit_test_api.apis.paths.request_body_post_required_default_validation_request_body import RequestBodyPostRequiredDefaultValidationRequestBody @@ -323,6 +325,8 @@ PathToApi = typing.TypedDict( PathValues.RESPONSE_BODY_POST_REF_IN_ONEOF_RESPONSE_BODY_FOR_CONTENT_TYPES: ResponseBodyPostRefInOneofResponseBodyForContentTypes, PathValues.REQUEST_BODY_POST_REF_IN_ANYOF_REQUEST_BODY: RequestBodyPostRefInAnyofRequestBody, PathValues.RESPONSE_BODY_POST_REF_IN_ANYOF_RESPONSE_BODY_FOR_CONTENT_TYPES: ResponseBodyPostRefInAnyofResponseBodyForContentTypes, + PathValues.REQUEST_BODY_POST_REF_IN_NOT_REQUEST_BODY: RequestBodyPostRefInNotRequestBody, + PathValues.RESPONSE_BODY_POST_REF_IN_NOT_RESPONSE_BODY_FOR_CONTENT_TYPES: ResponseBodyPostRefInNotResponseBodyForContentTypes, PathValues.REQUEST_BODY_POST_REQUIRED_VALIDATION_REQUEST_BODY: RequestBodyPostRequiredValidationRequestBody, PathValues.RESPONSE_BODY_POST_REQUIRED_VALIDATION_RESPONSE_BODY_FOR_CONTENT_TYPES: ResponseBodyPostRequiredValidationResponseBodyForContentTypes, PathValues.REQUEST_BODY_POST_REQUIRED_DEFAULT_VALIDATION_REQUEST_BODY: RequestBodyPostRequiredDefaultValidationRequestBody, @@ -500,6 +504,8 @@ path_to_api = PathToApi( PathValues.RESPONSE_BODY_POST_REF_IN_ONEOF_RESPONSE_BODY_FOR_CONTENT_TYPES: ResponseBodyPostRefInOneofResponseBodyForContentTypes, PathValues.REQUEST_BODY_POST_REF_IN_ANYOF_REQUEST_BODY: RequestBodyPostRefInAnyofRequestBody, PathValues.RESPONSE_BODY_POST_REF_IN_ANYOF_RESPONSE_BODY_FOR_CONTENT_TYPES: ResponseBodyPostRefInAnyofResponseBodyForContentTypes, + PathValues.REQUEST_BODY_POST_REF_IN_NOT_REQUEST_BODY: RequestBodyPostRefInNotRequestBody, + PathValues.RESPONSE_BODY_POST_REF_IN_NOT_RESPONSE_BODY_FOR_CONTENT_TYPES: ResponseBodyPostRefInNotResponseBodyForContentTypes, PathValues.REQUEST_BODY_POST_REQUIRED_VALIDATION_REQUEST_BODY: RequestBodyPostRequiredValidationRequestBody, PathValues.RESPONSE_BODY_POST_REQUIRED_VALIDATION_RESPONSE_BODY_FOR_CONTENT_TYPES: ResponseBodyPostRequiredValidationResponseBodyForContentTypes, PathValues.REQUEST_BODY_POST_REQUIRED_DEFAULT_VALIDATION_REQUEST_BODY: RequestBodyPostRequiredDefaultValidationRequestBody, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/paths/request_body_post_ref_in_not_request_body.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/paths/request_body_post_ref_in_not_request_body.py new file mode 100644 index 00000000000..12dbc3510d7 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/paths/request_body_post_ref_in_not_request_body.py @@ -0,0 +1,7 @@ +from unit_test_api.paths.request_body_post_ref_in_not_request_body.post import ApiForpost + + +class RequestBodyPostRefInNotRequestBody( + ApiForpost, +): + pass diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/paths/response_body_post_ref_in_not_response_body_for_content_types.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/paths/response_body_post_ref_in_not_response_body_for_content_types.py new file mode 100644 index 00000000000..383fa2cf0e1 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/paths/response_body_post_ref_in_not_response_body_for_content_types.py @@ -0,0 +1,7 @@ +from unit_test_api.paths.response_body_post_ref_in_not_response_body_for_content_types.post import ApiForpost + + +class ResponseBodyPostRefInNotResponseBodyForContentTypes( + ApiForpost, +): + pass diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/content_type_json_api.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/content_type_json_api.py index 074fe5d7b16..0e5d3b26c39 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/content_type_json_api.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/content_type_json_api.py @@ -153,6 +153,8 @@ from unit_test_api.paths.request_body_post_ref_in_anyof_request_body.post import from unit_test_api.paths.response_body_post_ref_in_anyof_response_body_for_content_types.post import PostRefInAnyofResponseBodyForContentTypes from unit_test_api.paths.request_body_post_ref_in_items_request_body.post import PostRefInItemsRequestBody from unit_test_api.paths.response_body_post_ref_in_items_response_body_for_content_types.post import PostRefInItemsResponseBodyForContentTypes +from unit_test_api.paths.request_body_post_ref_in_not_request_body.post import PostRefInNotRequestBody +from unit_test_api.paths.response_body_post_ref_in_not_response_body_for_content_types.post import PostRefInNotResponseBodyForContentTypes from unit_test_api.paths.request_body_post_ref_in_oneof_request_body.post import PostRefInOneofRequestBody from unit_test_api.paths.response_body_post_ref_in_oneof_response_body_for_content_types.post import PostRefInOneofResponseBodyForContentTypes from unit_test_api.paths.request_body_post_ref_in_property_request_body.post import PostRefInPropertyRequestBody @@ -328,6 +330,8 @@ class ContentTypeJsonApi( PostRefInAnyofResponseBodyForContentTypes, PostRefInItemsRequestBody, PostRefInItemsResponseBodyForContentTypes, + PostRefInNotRequestBody, + PostRefInNotResponseBodyForContentTypes, PostRefInOneofRequestBody, PostRefInOneofResponseBodyForContentTypes, PostRefInPropertyRequestBody, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/operation_request_body_api.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/operation_request_body_api.py index db020cfacd6..2f64723d300 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/operation_request_body_api.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/operation_request_body_api.py @@ -81,6 +81,7 @@ from unit_test_api.paths.request_body_post_ref_in_additionalproperties_request_b from unit_test_api.paths.request_body_post_ref_in_allof_request_body.post import PostRefInAllofRequestBody from unit_test_api.paths.request_body_post_ref_in_anyof_request_body.post import PostRefInAnyofRequestBody from unit_test_api.paths.request_body_post_ref_in_items_request_body.post import PostRefInItemsRequestBody +from unit_test_api.paths.request_body_post_ref_in_not_request_body.post import PostRefInNotRequestBody from unit_test_api.paths.request_body_post_ref_in_oneof_request_body.post import PostRefInOneofRequestBody from unit_test_api.paths.request_body_post_ref_in_property_request_body.post import PostRefInPropertyRequestBody from unit_test_api.paths.request_body_post_required_default_validation_request_body.post import PostRequiredDefaultValidationRequestBody @@ -170,6 +171,7 @@ class OperationRequestBodyApi( PostRefInAllofRequestBody, PostRefInAnyofRequestBody, PostRefInItemsRequestBody, + PostRefInNotRequestBody, PostRefInOneofRequestBody, PostRefInPropertyRequestBody, PostRequiredDefaultValidationRequestBody, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/path_post_api.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/path_post_api.py index de323d225d2..3003735504e 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/path_post_api.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/path_post_api.py @@ -153,6 +153,8 @@ from unit_test_api.paths.request_body_post_ref_in_anyof_request_body.post import from unit_test_api.paths.response_body_post_ref_in_anyof_response_body_for_content_types.post import PostRefInAnyofResponseBodyForContentTypes from unit_test_api.paths.request_body_post_ref_in_items_request_body.post import PostRefInItemsRequestBody from unit_test_api.paths.response_body_post_ref_in_items_response_body_for_content_types.post import PostRefInItemsResponseBodyForContentTypes +from unit_test_api.paths.request_body_post_ref_in_not_request_body.post import PostRefInNotRequestBody +from unit_test_api.paths.response_body_post_ref_in_not_response_body_for_content_types.post import PostRefInNotResponseBodyForContentTypes from unit_test_api.paths.request_body_post_ref_in_oneof_request_body.post import PostRefInOneofRequestBody from unit_test_api.paths.response_body_post_ref_in_oneof_response_body_for_content_types.post import PostRefInOneofResponseBodyForContentTypes from unit_test_api.paths.request_body_post_ref_in_property_request_body.post import PostRefInPropertyRequestBody @@ -328,6 +330,8 @@ class PathPostApi( PostRefInAnyofResponseBodyForContentTypes, PostRefInItemsRequestBody, PostRefInItemsResponseBodyForContentTypes, + PostRefInNotRequestBody, + PostRefInNotResponseBodyForContentTypes, PostRefInOneofRequestBody, PostRefInOneofResponseBodyForContentTypes, PostRefInPropertyRequestBody, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/ref_api.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/ref_api.py index 299a7061279..7775cd1104f 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/ref_api.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/ref_api.py @@ -19,6 +19,8 @@ from unit_test_api.paths.request_body_post_ref_in_anyof_request_body.post import from unit_test_api.paths.response_body_post_ref_in_anyof_response_body_for_content_types.post import PostRefInAnyofResponseBodyForContentTypes from unit_test_api.paths.request_body_post_ref_in_items_request_body.post import PostRefInItemsRequestBody from unit_test_api.paths.response_body_post_ref_in_items_response_body_for_content_types.post import PostRefInItemsResponseBodyForContentTypes +from unit_test_api.paths.request_body_post_ref_in_not_request_body.post import PostRefInNotRequestBody +from unit_test_api.paths.response_body_post_ref_in_not_response_body_for_content_types.post import PostRefInNotResponseBodyForContentTypes from unit_test_api.paths.request_body_post_ref_in_oneof_request_body.post import PostRefInOneofRequestBody from unit_test_api.paths.response_body_post_ref_in_oneof_response_body_for_content_types.post import PostRefInOneofResponseBodyForContentTypes from unit_test_api.paths.request_body_post_ref_in_property_request_body.post import PostRefInPropertyRequestBody @@ -36,6 +38,8 @@ class RefApi( PostRefInAnyofResponseBodyForContentTypes, PostRefInItemsRequestBody, PostRefInItemsResponseBodyForContentTypes, + PostRefInNotRequestBody, + PostRefInNotResponseBodyForContentTypes, PostRefInOneofRequestBody, PostRefInOneofResponseBodyForContentTypes, PostRefInPropertyRequestBody, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/response_content_content_type_schema_api.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/response_content_content_type_schema_api.py index 8c65e4ec0db..0e0e47d3f8a 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/response_content_content_type_schema_api.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/apis/tags/response_content_content_type_schema_api.py @@ -81,6 +81,7 @@ from unit_test_api.paths.response_body_post_ref_in_additionalproperties_response from unit_test_api.paths.response_body_post_ref_in_allof_response_body_for_content_types.post import PostRefInAllofResponseBodyForContentTypes from unit_test_api.paths.response_body_post_ref_in_anyof_response_body_for_content_types.post import PostRefInAnyofResponseBodyForContentTypes from unit_test_api.paths.response_body_post_ref_in_items_response_body_for_content_types.post import PostRefInItemsResponseBodyForContentTypes +from unit_test_api.paths.response_body_post_ref_in_not_response_body_for_content_types.post import PostRefInNotResponseBodyForContentTypes from unit_test_api.paths.response_body_post_ref_in_oneof_response_body_for_content_types.post import PostRefInOneofResponseBodyForContentTypes from unit_test_api.paths.response_body_post_ref_in_property_response_body_for_content_types.post import PostRefInPropertyResponseBodyForContentTypes from unit_test_api.paths.response_body_post_required_default_validation_response_body_for_content_types.post import PostRequiredDefaultValidationResponseBodyForContentTypes @@ -170,6 +171,7 @@ class ResponseContentContentTypeSchemaApi( PostRefInAllofResponseBodyForContentTypes, PostRefInAnyofResponseBodyForContentTypes, PostRefInItemsResponseBodyForContentTypes, + PostRefInNotResponseBodyForContentTypes, PostRefInOneofResponseBodyForContentTypes, PostRefInPropertyResponseBodyForContentTypes, PostRequiredDefaultValidationResponseBodyForContentTypes, diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_not.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_not.py new file mode 100644 index 00000000000..f44600d0cad --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/model/ref_in_not.py @@ -0,0 +1,115 @@ +# coding: utf-8 + +""" + openapi 3.0.3 sample spec + + sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501 + + The version of the OpenAPI document: 0.0.1 + Generated by: https://openapi-generator.tech +""" + +import re # noqa: F401 +import sys # noqa: F401 +import typing # noqa: F401 +import functools # noqa: F401 + +from frozendict import frozendict # noqa: F401 + +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + NoneClass, + BoolClass, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + + +class RefInNot( + ComposedSchema +): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + PropertyNamedRefThatIsNotAReference + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'RefInNot': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) + +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py index 92d95b0b8ab..3dd512a4cd2 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/models/__init__.py @@ -82,6 +82,7 @@ from unit_test_api.model.ref_in_additionalproperties import RefInAdditionalprope from unit_test_api.model.ref_in_allof import RefInAllof from unit_test_api.model.ref_in_anyof import RefInAnyof from unit_test_api.model.ref_in_items import RefInItems +from unit_test_api.model.ref_in_not import RefInNot from unit_test_api.model.ref_in_oneof import RefInOneof from unit_test_api.model.ref_in_property import RefInProperty from unit_test_api.model.required_default_validation import RequiredDefaultValidation diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/__init__.py index 1de59a0d52b..2522dcf8f19 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/__init__.py +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/__init__.py @@ -152,6 +152,8 @@ class PathValues(str, enum.Enum): RESPONSE_BODY_POST_REF_IN_ONEOF_RESPONSE_BODY_FOR_CONTENT_TYPES = "/responseBody/postRefInOneofResponseBodyForContentTypes" REQUEST_BODY_POST_REF_IN_ANYOF_REQUEST_BODY = "/requestBody/postRefInAnyofRequestBody" RESPONSE_BODY_POST_REF_IN_ANYOF_RESPONSE_BODY_FOR_CONTENT_TYPES = "/responseBody/postRefInAnyofResponseBodyForContentTypes" + REQUEST_BODY_POST_REF_IN_NOT_REQUEST_BODY = "/requestBody/postRefInNotRequestBody" + RESPONSE_BODY_POST_REF_IN_NOT_RESPONSE_BODY_FOR_CONTENT_TYPES = "/responseBody/postRefInNotResponseBodyForContentTypes" REQUEST_BODY_POST_REQUIRED_VALIDATION_REQUEST_BODY = "/requestBody/postRequiredValidationRequestBody" RESPONSE_BODY_POST_REQUIRED_VALIDATION_RESPONSE_BODY_FOR_CONTENT_TYPES = "/responseBody/postRequiredValidationResponseBodyForContentTypes" REQUEST_BODY_POST_REQUIRED_DEFAULT_VALIDATION_REQUEST_BODY = "/requestBody/postRequiredDefaultValidationRequestBody" diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/request_body_post_ref_in_not_request_body/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/request_body_post_ref_in_not_request_body/__init__.py new file mode 100644 index 00000000000..3d3ad62339f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/request_body_post_ref_in_not_request_body/__init__.py @@ -0,0 +1,7 @@ +# 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 unit_test_api.paths.request_body_post_ref_in_not_request_body import Api + +from unit_test_api.paths import PathValues + +path = PathValues.REQUEST_BODY_POST_REF_IN_NOT_REQUEST_BODY \ No newline at end of file diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/request_body_post_ref_in_not_request_body/post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/request_body_post_ref_in_not_request_body/post.py new file mode 100644 index 00000000000..42d8a981428 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/request_body_post_ref_in_not_request_body/post.py @@ -0,0 +1,244 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +from dataclasses import dataclass +import re # noqa: F401 +import sys # noqa: F401 +import typing +import urllib3 +import functools # noqa: F401 +from urllib3._collections import HTTPHeaderDict + +from unit_test_api import api_client, exceptions +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + NoneClass, + BoolClass, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference + +from . import path + +# body param + + +class SchemaForRequestBodyApplicationJson( + ComposedSchema +): + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + PropertyNamedRefThatIsNotAReference + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'SchemaForRequestBodyApplicationJson': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) + + +request_body_body = api_client.RequestBody( + content={ + 'application/json': api_client.MediaType( + schema=SchemaForRequestBodyApplicationJson), + }, + required=True, +) + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: Unset = unset + headers: Unset = unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, +) +_status_code_to_response = { + '200': _response_for_200, +} + + +class BaseApi(api_client.Api): + + def _post_ref_in_not_request_body( + self: api_client.Api, + body: typing.Union[SchemaForRequestBodyApplicationJson], + content_type: str = 'application/json', + 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 + """ + used_path = path.value + + _headers = HTTPHeaderDict() + # TODO add cookie handling + + if body is unset: + raise exceptions.ApiValueError( + 'The required body parameter has an invalid value of: unset. Set a valid value instead') + _fields = None + _body = None + serialized_data = request_body_body.serialize(body, content_type) + _headers.add('Content-Type', content_type) + if 'fields' in serialized_data: + _fields = serialized_data['fields'] + elif 'body' in serialized_data: + _body = serialized_data['body'] + response = self.api_client.call_api( + resource_path=used_path, + method='post'.upper(), + headers=_headers, + fields=_fields, + body=_body, + 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(api_response=api_response) + + return api_response + + +class PostRefInNotRequestBody(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + def post_ref_in_not_request_body( + self: BaseApi, + body: typing.Union[SchemaForRequestBodyApplicationJson], + content_type: str = 'application/json', + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization + ]: + return self._post_ref_in_not_request_body( + body=body, + content_type=content_type, + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForpost(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + def post( + self: BaseApi, + body: typing.Union[SchemaForRequestBodyApplicationJson], + content_type: str = 'application/json', + stream: bool = False, + timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None, + skip_deserialization: bool = False, + ) -> typing.Union[ + ApiResponseFor200, + api_client.ApiResponseWithoutDeserialization + ]: + return self._post_ref_in_not_request_body( + body=body, + content_type=content_type, + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/response_body_post_ref_in_not_response_body_for_content_types/__init__.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/response_body_post_ref_in_not_response_body_for_content_types/__init__.py new file mode 100644 index 00000000000..81c335c672f --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/response_body_post_ref_in_not_response_body_for_content_types/__init__.py @@ -0,0 +1,7 @@ +# 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 unit_test_api.paths.response_body_post_ref_in_not_response_body_for_content_types import Api + +from unit_test_api.paths import PathValues + +path = PathValues.RESPONSE_BODY_POST_REF_IN_NOT_RESPONSE_BODY_FOR_CONTENT_TYPES \ No newline at end of file diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/response_body_post_ref_in_not_response_body_for_content_types/post.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/response_body_post_ref_in_not_response_body_for_content_types/post.py new file mode 100644 index 00000000000..be153d05fb9 --- /dev/null +++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/paths/response_body_post_ref_in_not_response_body_for_content_types/post.py @@ -0,0 +1,228 @@ +# coding: utf-8 + +""" + + + Generated by: https://openapi-generator.tech +""" + +from dataclasses import dataclass +import re # noqa: F401 +import sys # noqa: F401 +import typing +import urllib3 +import functools # noqa: F401 +from urllib3._collections import HTTPHeaderDict + +from unit_test_api import api_client, exceptions +import decimal # noqa: F401 +from datetime import date, datetime # noqa: F401 +from frozendict import frozendict # noqa: F401 + +from unit_test_api.schemas import ( # noqa: F401 + AnyTypeSchema, + ComposedSchema, + DictSchema, + ListSchema, + StrSchema, + IntSchema, + Int32Schema, + Int64Schema, + Float32Schema, + Float64Schema, + NumberSchema, + UUIDSchema, + DateSchema, + DateTimeSchema, + DecimalSchema, + BoolSchema, + BinarySchema, + NoneSchema, + none_type, + Configuration, + Unset, + unset, + ComposedBase, + ListBase, + DictBase, + NoneBase, + StrBase, + IntBase, + Int32Base, + Int64Base, + Float32Base, + Float64Base, + NumberBase, + UUIDBase, + DateBase, + DateTimeBase, + BoolBase, + BinaryBase, + Schema, + NoneClass, + BoolClass, + _SchemaValidator, + _SchemaTypeChecker, + _SchemaEnumMaker +) + +from unit_test_api.model.property_named_ref_that_is_not_a_reference import PropertyNamedRefThatIsNotAReference + +from . import path + + + +class SchemaFor200ResponseBodyApplicationJson( + ComposedSchema +): + + @classmethod + @property + @functools.cache + def _composed_schemas(cls): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'allOf': [ + ], + 'oneOf': [ + ], + 'anyOf': [ + ], + 'not': + PropertyNamedRefThatIsNotAReference + } + + def __new__( + cls, + *args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes], + _configuration: typing.Optional[Configuration] = None, + **kwargs: typing.Type[Schema], + ) -> 'SchemaFor200ResponseBodyApplicationJson': + return super().__new__( + cls, + *args, + _configuration=_configuration, + **kwargs, + ) + + +@dataclass +class ApiResponseFor200(api_client.ApiResponse): + response: urllib3.HTTPResponse + body: typing.Union[ + SchemaFor200ResponseBodyApplicationJson, + ] + headers: Unset = unset + + +_response_for_200 = api_client.OpenApiResponse( + response_cls=ApiResponseFor200, + content={ + 'application/json': api_client.MediaType( + schema=SchemaFor200ResponseBodyApplicationJson), + }, +) +_status_code_to_response = { + '200': _response_for_200, +} +_all_accept_content_types = ( + 'application/json', +) + + +class BaseApi(api_client.Api): + + def _post_ref_in_not_response_body_for_content_types( + self: api_client.Api, + 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 + """ + used_path = path.value + + _headers = HTTPHeaderDict() + # TODO add cookie handling + if accept_content_types: + for accept_content_type in accept_content_types: + _headers.add('Accept', accept_content_type) + + response = self.api_client.call_api( + resource_path=used_path, + method='post'.upper(), + headers=_headers, + 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(api_response=api_response) + + return api_response + + +class PostRefInNotResponseBodyForContentTypes(BaseApi): + # this class is used by api classes that refer to endpoints with operationId fn names + + def post_ref_in_not_response_body_for_content_types( + self: BaseApi, + 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._post_ref_in_not_response_body_for_content_types( + accept_content_types=accept_content_types, + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + + +class ApiForpost(BaseApi): + # this class is used by api classes that refer to endpoints by path and http method names + + def post( + self: BaseApi, + 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._post_ref_in_not_response_body_for_content_types( + accept_content_types=accept_content_types, + stream=stream, + timeout=timeout, + skip_deserialization=skip_deserialization + ) + +