diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenHeader.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenHeader.java index 28c965937b9..f2d01ba7758 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenHeader.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenHeader.java @@ -17,9 +17,6 @@ package org.openapitools.codegen; -import org.openapitools.codegen.utils.ModelUtils; - -import java.util.Map; import java.util.Objects; /** @@ -27,42 +24,11 @@ * A unique parameter is defined by a combination of a name and location. * Parameters may be located in a path, query, header or cookie. */ -public class CodegenHeader extends CodegenRequestBody { - public boolean isExplode; - public String style; - - public boolean isDeprecated; - protected CodegenSchema schema; - - public CodegenSchema getSetSchema() { - if (schema != null) { - return schema; - } - if (content != null) { - for (CodegenMediaType codegenMediaType: content.values()) { - return codegenMediaType.getSchema(); - } - } - return null; - } - - public String getSetSchemaJsonPath(String jsonPath) { - if (schema != null) { - return jsonPath + "/schema"; - } - if (content != null) { - for (Map.Entry entry: content.entrySet()) { - if (entry.getValue().getSchema() != null) { - String contentType = entry.getKey(); - return jsonPath + "/content/" + ModelUtils.encodeSlashes(contentType) + "/schema"; - } - } - } - return null; - } +public class CodegenHeader extends CodegenHeaderBase implements OpenApiLocation { + protected CodegenRefInfo refInfo; @Override public int hashCode() { - return Objects.hash(refClass, name, isExplode, description, unescapedDescription, style, example, jsonSchema, vendorExtensions, isDeprecated, required, schema, content, ref, refModule, imports, componentModule); + return Objects.hash(name, isExplode, description, unescapedDescription, style, example, jsonSchema, vendorExtensions, isDeprecated, required, schema, content, refInfo, imports, componentModule); } @Override @@ -71,18 +37,12 @@ public boolean equals(Object o) { if (!(o instanceof CodegenHeader)) return false; if (! super.equals(o)) return false; CodegenHeader that = (CodegenHeader) o; - return isExplode == that.isExplode && - isDeprecated == that.isDeprecated && - Objects.equals(schema, that.getSchema()) && - Objects.equals(style, that.style); + return Objects.equals(refInfo, that.refInfo); } protected void addInstanceInfo(StringBuilder sb) { super.addInstanceInfo(sb); - sb.append(", isExplode=").append(isExplode); - sb.append(", style='").append(style).append('\''); - sb.append(", isDeprecated=").append(isDeprecated); - sb.append(", schema=").append(schema); + sb.append(", refInfo=").append(refInfo); } @Override @@ -93,15 +53,8 @@ public String toString() { return sb.toString(); } - @Override - public CodegenHeader getRef() { return (CodegenHeader) ref; } + public CodegenRefInfo getRefInfo() { return refInfo; } - public CodegenSchema getSchema() { - return schema; - } - - public void setSchema(CodegenSchema schema) { - this.schema = schema; - } + public void setRefInfo(CodegenRefInfo refInfo) { this.refInfo = refInfo; } } diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenHeaderBase.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenHeaderBase.java new file mode 100644 index 00000000000..cad898b9b18 --- /dev/null +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenHeaderBase.java @@ -0,0 +1,91 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * Copyright 2018 SmartBear Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen; + +import org.openapitools.codegen.utils.ModelUtils; + +import java.util.Map; +import java.util.Objects; + +/** + * Describes a single operation parameter in the OAS specification. + * A unique parameter is defined by a combination of a name and location. + * Parameters may be located in a path, query, header or cookie. + */ +abstract class CodegenHeaderBase extends CodegenRequestBodyBase { + public boolean isExplode; + public String style; + public boolean isDeprecated; + protected CodegenSchema schema; + + public CodegenSchema getSetSchema() { + if (schema != null) { + return schema; + } + if (content != null) { + for (CodegenMediaType codegenMediaType: content.values()) { + return codegenMediaType.getSchema(); + } + } + return null; + } + + public String getSetSchemaJsonPath(String jsonPath) { + if (schema != null) { + return jsonPath + "/schema"; + } + if (content != null) { + for (Map.Entry entry: content.entrySet()) { + if (entry.getValue().getSchema() != null) { + String contentType = entry.getKey(); + return jsonPath + "/content/" + ModelUtils.encodeSlashes(contentType) + "/schema"; + } + } + } + return null; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CodegenHeaderBase)) return false; + if (! super.equals(o)) return false; + CodegenHeaderBase that = (CodegenHeaderBase) o; + return isExplode == that.isExplode && + isDeprecated == that.isDeprecated && + Objects.equals(schema, that.getSchema()) && + Objects.equals(style, that.style); + } + + protected void addInstanceInfo(StringBuilder sb) { + super.addInstanceInfo(sb); + sb.append(", isExplode=").append(isExplode); + sb.append(", style='").append(style).append('\''); + sb.append(", isDeprecated=").append(isDeprecated); + sb.append(", schema=").append(schema); + } + + public CodegenSchema getSchema() { + return schema; + } + + public void setSchema(CodegenSchema schema) { + this.schema = schema; + } +} + diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java index 315072e7912..6d8d110a1a1 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenOperation.java @@ -39,8 +39,8 @@ public class CodegenOperation { public List headerParams = new ArrayList(); public List implicitHeadersParams = new ArrayList(); public List cookieParams = new ArrayList(); - public List requiredParams = new ArrayList(); - public List optionalParams = new ArrayList(); + public List requiredParams = new ArrayList(); + public List optionalParams = new ArrayList(); public List authMethods; public Map tags; public TreeMap responses = null; @@ -176,9 +176,9 @@ public Map getContentTypeToOperation() { return null; } LinkedHashMap content; - CodegenRequestBody ref = (CodegenRequestBody) requestBody.getRef(); - if (ref != null) { - content = ref.getContent(); + CodegenRefInfo refInfo = requestBody.getRefInfo(); + if (refInfo != null) { + content = refInfo.getRef().getContent(); } else { content = requestBody.getContent(); } diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java index ffd94558d39..587f4257dba 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenParameter.java @@ -24,17 +24,20 @@ * A unique parameter is defined by a combination of a name and location. * Parameters may be located in a path, query, header or cookie. */ -public class CodegenParameter extends CodegenHeader { +public class CodegenParameter extends CodegenHeaderBase implements OpenApiLocation { public boolean isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isAllowEmptyValue, isDeepObject; // stores the openapi name property public String baseName; + protected CodegenRefInfo refInfo; - public CodegenParameter getRef() { return (CodegenParameter) ref; } + public CodegenRefInfo getRefInfo() { return refInfo; } + + public void setRefInfo(CodegenRefInfo refInfo) { this.refInfo = refInfo; } @Override public int hashCode() { - return Objects.hash(refClass, name, isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isExplode, baseName, description, unescapedDescription, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, vendorExtensions, isDeprecated, required, schema, content, ref, refModule, imports, componentModule); + return Objects.hash(name, isFormParam, isQueryParam, isPathParam, isHeaderParam, isCookieParam, isBodyParam, isExplode, baseName, description, unescapedDescription, style, isDeepObject, isAllowEmptyValue, example, jsonSchema, vendorExtensions, isDeprecated, required, schema, content, refInfo, imports, componentModule); } @Override @@ -49,6 +52,7 @@ public boolean equals(Object o) { isHeaderParam == that.isHeaderParam && isCookieParam == that.isCookieParam && isBodyParam == that.isBodyParam && + Objects.equals(refInfo, that.refInfo) && Objects.equals(baseName, that.baseName) && Objects.equals(isDeepObject, that.isDeepObject); } @@ -64,6 +68,7 @@ protected void addInstanceInfo(StringBuilder sb) { sb.append(", deepObject='").append(isDeepObject).append('\''); sb.append(", allowEmptyValue='").append(isAllowEmptyValue).append('\''); sb.append(", baseName='").append(baseName).append('\''); + sb.append(", refInfo='").append(refInfo).append('\''); } @Override diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRefInfo.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRefInfo.java new file mode 100644 index 00000000000..60588291316 --- /dev/null +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRefInfo.java @@ -0,0 +1,51 @@ +package org.openapitools.codegen; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.Objects; + +@JsonIgnoreProperties({"ref"}) +public class CodegenRefInfo { + private T ref; + private String refClass; + private String refModule; + + protected void addInstanceInfo(StringBuilder sb) { + sb.append("refModule=").append(refModule); + sb.append(", refClass=").append(refClass); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("CodegenRefInfo{"); + addInstanceInfo(sb); + sb.append('}'); + return sb.toString(); + } + + @Override + public int hashCode() { + // ref must be omitted here for generation to work + return Objects.hash(refClass, refModule); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CodegenRefInfo)) return false; + CodegenRefInfo that = (CodegenRefInfo) o; + return Objects.equals(refModule, that.refModule) && + Objects.equals(refClass, that.refClass) && + Objects.equals(ref, that.ref); + } + + public CodegenRefInfo(T ref, String refClass, String refModule) { + this.ref = ref; + this.refClass = refClass; + this.refModule = refModule ; + } + + public T getRef() { return ref; } + public String getRefClass() { return refClass; } + public String getRefModule() { return refModule; } +} diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRequestBody.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRequestBody.java index 4388740c30f..e8be8a91482 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRequestBody.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRequestBody.java @@ -1,92 +1,32 @@ package org.openapitools.codegen; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Map; import java.util.Objects; -import java.util.Set; /** * Describes a single operation parameter in the OAS specification. * A unique parameter is defined by a combination of a name and location. * Parameters may be located in a path, query, header or cookie. */ -public class CodegenRequestBody implements OpenApiComponent { - protected String description, unescapedDescription; - - protected CodegenKey name; - protected String example; // example value (x-example) - protected String jsonSchema; - protected Map vendorExtensions = new HashMap(); - /** - * Determines whether this parameter is mandatory. If the parameter is in "path", - * this property is required and its value MUST be true. Otherwise, the property - * MAY be included and its default value is false. - */ - protected boolean required; - protected LinkedHashMap content; - protected Object ref; - protected String refModule; - protected Set imports = new HashSet(); - protected String componentModule; - protected String refClass; - - public String getComponentModule() { - return componentModule; - } - - public void setComponentModule(String componentModule) { - this.componentModule = componentModule; - } - - public String getRefClass() { - return refClass; - } - - public void setRefClass(String refClass) { - this.refClass = refClass; - } +public class CodegenRequestBody extends CodegenRequestBodyBase implements OpenApiLocation { + protected CodegenRefInfo refInfo; @Override public int hashCode() { - return Objects.hash(refClass, description, unescapedDescription, name, example, jsonSchema, vendorExtensions, required, content, ref, refModule, imports, componentModule); + return Objects.hash(description, unescapedDescription, name, example, jsonSchema, vendorExtensions, required, content, refInfo, imports, componentModule); } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof CodegenRequestBody)) return false; + if (! super.equals(o)) return false; CodegenRequestBody that = (CodegenRequestBody) o; - return required == that.required && - Objects.equals(refClass, that.refClass) && - Objects.equals(name, that.name) && - Objects.equals(componentModule, that.componentModule) && - Objects.equals(ref, that.getRef()) && - Objects.equals(imports, that.imports) && - Objects.equals(refModule, that.getRefModule()) && - Objects.equals(content, that.getContent()) && - Objects.equals(description, that.description) && - Objects.equals(unescapedDescription, that.unescapedDescription) && - Objects.equals(example, that.example) && - Objects.equals(jsonSchema, that.jsonSchema) && - Objects.equals(vendorExtensions, that.vendorExtensions); + return Objects.equals(refInfo, that.getRefInfo()); } protected void addInstanceInfo(StringBuilder sb) { - sb.append(", description='").append(description).append('\''); - sb.append(", unescapedDescription='").append(unescapedDescription).append('\''); - sb.append(", name='").append(name).append('\''); - sb.append(", example='").append(example).append('\''); - sb.append(", jsonSchema='").append(jsonSchema).append('\''); - sb.append(", vendorExtensions=").append(vendorExtensions); - sb.append(", required=").append(required); - sb.append(", content=").append(content); - sb.append(", ref=").append(ref); - sb.append(", refModule=").append(refModule); - sb.append(", refClass=").append(refClass); - sb.append(", imports=").append(imports); - sb.append(", componentModule=").append(componentModule); + super.addInstanceInfo(sb); + sb.append(", refInfo=").append(refInfo); } @Override @@ -97,36 +37,8 @@ public String toString() { return sb.toString(); } - public LinkedHashMap getContent() { - return content; - } - - public void setContent(LinkedHashMap content) { - this.content = content; - } - - public CodegenKey getName() { return name; } - - public void setName(CodegenKey name) { this.name=name; } - - public CodegenRequestBody getRef() { return (CodegenRequestBody) ref; } - - public void setRef(Object ref) { this.ref = ref; } - - public String getRefModule() { return refModule; } - - public void setRefModule(String refModule) { this.refModule=refModule; } - - public String getDescription() { return description; } - - public void setDescription(String description) { this.description=description; } - - public String getExample() { return example; } - - public void setExample(String example) { this.example=example; } - - public Map getVendorExtensions() { return vendorExtensions; } + public CodegenRefInfo getRefInfo() { return refInfo; } - public void setVendorExtensions(Map vendorExtensions) { this.vendorExtensions = vendorExtensions; } + public void setRefInfo(CodegenRefInfo refInfo) { this.refInfo = refInfo; } } diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRequestBodyBase.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRequestBodyBase.java new file mode 100644 index 00000000000..81b33f39b6c --- /dev/null +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenRequestBodyBase.java @@ -0,0 +1,99 @@ +package org.openapitools.codegen; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * Describes a single operation parameter in the OAS specification. + * A unique parameter is defined by a combination of a name and location. + * Parameters may be located in a path, query, header or cookie. + */ +abstract class CodegenRequestBodyBase { + protected String description, unescapedDescription; + + protected String example; // example value (x-example) + protected String jsonSchema; + protected Map vendorExtensions = new HashMap(); + /** + * Determines whether this parameter is mandatory. If the parameter is in "path", + * this property is required and its value MUST be true. Otherwise, the property + * MAY be included and its default value is false. + */ + protected boolean required; + protected LinkedHashMap content; + protected Set imports = new HashSet(); + protected String componentModule; + protected CodegenKey name; + + public String getComponentModule() { + return componentModule; + } + + public void setComponentModule(String componentModule) { + this.componentModule = componentModule; + } + + // always set + // used for spec name (name.getName) + // module name (name.getSnakeCaseName) + // class name (name.getCamelCaseName) + // used when instances are defined inline and do not $ref another location + public CodegenKey getName() { return name; } + + public void setName(CodegenKey name) { this.name = name; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CodegenRequestBodyBase)) return false; + CodegenRequestBodyBase that = (CodegenRequestBodyBase) o; + return required == that.required && + Objects.equals(name, that.name) && + Objects.equals(componentModule, that.componentModule) && + Objects.equals(imports, that.imports) && + Objects.equals(content, that.getContent()) && + Objects.equals(description, that.description) && + Objects.equals(unescapedDescription, that.unescapedDescription) && + Objects.equals(example, that.example) && + Objects.equals(jsonSchema, that.jsonSchema) && + Objects.equals(vendorExtensions, that.vendorExtensions); + } + + protected void addInstanceInfo(StringBuilder sb) { + sb.append(", description='").append(name).append('\''); + sb.append(", description='").append(description).append('\''); + sb.append(", unescapedDescription='").append(unescapedDescription).append('\''); + sb.append(", example='").append(example).append('\''); + sb.append(", jsonSchema='").append(jsonSchema).append('\''); + sb.append(", vendorExtensions=").append(vendorExtensions); + sb.append(", required=").append(required); + sb.append(", content=").append(content); + sb.append(", imports=").append(imports); + sb.append(", componentModule=").append(componentModule); + } + + public LinkedHashMap getContent() { + return content; + } + + public void setContent(LinkedHashMap content) { + this.content = content; + } + + public String getDescription() { return description; } + + public void setDescription(String description) { this.description=description; } + + public String getExample() { return example; } + + public void setExample(String example) { this.example=example; } + + public Map getVendorExtensions() { return vendorExtensions; } + + public void setVendorExtensions(Map vendorExtensions) { this.vendorExtensions = vendorExtensions; } +} + diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java index 59c0efa727e..eb87cffb1b3 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenResponse.java @@ -19,7 +19,7 @@ import java.util.*; -public class CodegenResponse implements OpenApiComponent { +public class CodegenResponse implements OpenApiLocation { private CodegenKey name; private Map headers; public String message; @@ -27,18 +27,16 @@ public class CodegenResponse implements OpenApiComponent { public String jsonSchema; public Map vendorExtensions = new HashMap(); private LinkedHashMap content; - private CodegenResponse ref; + private CodegenRefInfo refInfo; public Set imports = new TreeSet<>(); - private String refModule; - private String refClass; private String componentModule; @Override public int hashCode() { - return Objects.hash(refClass, name, message, examples, + return Objects.hash(name, message, examples, jsonSchema, vendorExtensions, headers, content, - ref, imports, refModule, componentModule); + refInfo, imports, componentModule); } @Override @@ -47,16 +45,14 @@ public boolean equals(Object o) { if (!(o instanceof CodegenResponse)) return false; CodegenResponse that = (CodegenResponse) o; return Objects.equals(name, that.name) && - Objects.equals(refClass, that.refClass) && Objects.equals(imports, that.imports) && - Objects.equals(ref, that.getRef()) && + Objects.equals(refInfo, that.getRefInfo()) && Objects.equals(content, that.getContent()) && Objects.equals(headers, that.getHeaders()) && Objects.equals(message, that.message) && Objects.equals(examples, that.examples) && Objects.equals(jsonSchema, that.jsonSchema) && Objects.equals(vendorExtensions, that.vendorExtensions) && - Objects.equals(refModule, that.getRefModule()) && Objects.equals(componentModule, that.componentModule); } @@ -94,30 +90,16 @@ public String toString() { sb.append(", vendorExtensions=").append(vendorExtensions); sb.append(", headers=").append(headers); sb.append(", content=").append(content); - sb.append(", ref=").append(ref); - sb.append(", refModule=").append(refModule); - sb.append(", refClass=").append(refClass); + sb.append(", refInfo=").append(refInfo); sb.append(", imports=").append(imports); sb.append(", componentModule=").append(componentModule); sb.append('}'); return sb.toString(); } - public CodegenResponse getRef() { return ref; } + public CodegenRefInfo getRefInfo() { return refInfo; } - public void setRef(Object ref) { this.ref = (CodegenResponse) ref; } - - public String getRefModule() { return refModule; } - - public void setRefModule(String refModule) { this.refModule=refModule; } - - public String getRefClass() { - return refClass; - } - - public void setRefClass(String refClass) { - this.refClass = refClass; - } + public void setRefInfo(CodegenRefInfo refInfo) { this.refInfo = refInfo; } public CodegenKey getName() { return name; } diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenSchema.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenSchema.java index 9884835882d..cb146d01e92 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenSchema.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/CodegenSchema.java @@ -18,18 +18,15 @@ package org.openapitools.codegen; import io.swagger.v3.oas.models.ExternalDocumentation; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import java.util.*; -@JsonIgnoreProperties({"ref"}) -public class CodegenSchema implements OpenApiSchema, OpenApiComponent { +public class CodegenSchema implements OpenApiSchema, OpenApiLocation { // testCases are for autogenerated tests of schemas public HashMap testCases = new HashMap<>(); private String componentModule; public TreeSet imports; private ExternalDocumentation externalDocumentation; - public String refClass; /** * The value of the 'description' attribute in the OpenAPI schema. */ @@ -157,8 +154,7 @@ public class CodegenSchema implements OpenApiSchema, OpenApiComponent { private LinkedHashMap requiredProperties; private LinkedHashMap properties; private LinkedHashMap optionalProperties; - private CodegenSchema ref; - private String refModule; + private CodegenRefInfo refInfo; private boolean schemaIsFromAdditionalProperties; private boolean isBooleanSchemaTrue; private boolean isBooleanSchemaFalse; @@ -248,14 +244,6 @@ public void setIsBooleanSchemaFalse(boolean isBooleanSchemaFalse) { this.isBooleanSchemaFalse = isBooleanSchemaFalse; } - public String getRefClass() { - return refClass; - } - - public void setRefClass(String refClass) { - this.refClass = refClass; - } - public String getDescription() { return description; } @@ -586,13 +574,13 @@ public CodegenSchema getNot() { } @Override - public void setRef(Object ref) { - this.ref = (CodegenSchema) ref; + public void setRefInfo(CodegenRefInfo refInfo) { + this.refInfo = refInfo; } @Override - public CodegenSchema getRef() { - return ref; + public CodegenRefInfo getRefInfo() { + return refInfo; } @Override @@ -741,12 +729,7 @@ public void setHasMultipleTypes(boolean hasMultipleTypes) { @Override public void setOptionalProperties(LinkedHashMap optionalProperties) { this.optionalProperties = optionalProperties; } - public String getRefModule() { return refModule; } - - public void setRefModule(String refModule) { this.refModule=refModule; } - protected void addInstanceInfo(StringBuilder sb) { - sb.append(", refClass='").append(refClass).append('\''); sb.append(", description='").append(description).append('\''); sb.append(", name='").append(name).append('\''); sb.append(", defaultValue='").append(defaultValue).append('\''); @@ -813,8 +796,7 @@ protected void addInstanceInfo(StringBuilder sb) { sb.append(", requiredProperties=").append(requiredProperties); sb.append(", optionalProperties=").append(optionalProperties); sb.append(", properties=").append(properties); - sb.append(", ref=").append(ref); - sb.append(", refModule=").append(refModule); + sb.append(", refInfo=").append(refInfo); sb.append(", schemaIsFromAdditionalProperties=").append(schemaIsFromAdditionalProperties); sb.append(", isBooleanSchemaTrue=").append(isBooleanSchemaTrue); sb.append(", isBooleanSchemaFalse=").append(isBooleanSchemaFalse); @@ -896,12 +878,10 @@ public boolean equals(Object o) { Objects.equals(contains, that.getContains()) && Objects.equals(dependentRequired, that.getDependentRequired()) && Objects.equals(format, that.getFormat()) && - Objects.equals(ref, that.getRef()) && - Objects.equals(refModule, that.getRefModule()) && + Objects.equals(refInfo, that.getRefInfo()) && Objects.equals(requiredProperties, that.getRequiredProperties()) && Objects.equals(optionalProperties, that.getOptionalProperties()) && Objects.equals(properties, that.getProperties()) && - Objects.equals(refClass, that.refClass) && Objects.equals(description, that.description) && Objects.equals(name, that.name) && Objects.equals(defaultValue, that.defaultValue) && @@ -929,7 +909,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(refClass, description, + return Objects.hash(description, name, defaultValue, title, unescapedDescription, maxLength, minLength, pattern, example, minimum, maximum, @@ -945,8 +925,8 @@ public int hashCode() { xmlNamespace, isXmlWrapped, isNull, hasDiscriminatorWithNonEmptyMapping, hasMultipleTypes, schemaIsFromAdditionalProperties, isBooleanSchemaTrue, isBooleanSchemaFalse, - format, dependentRequired, contains, refModule, allOf, anyOf, oneOf, not, + format, dependentRequired, contains, allOf, anyOf, oneOf, not, properties, optionalProperties, requiredProperties, externalDocumentation, - discriminator, imports, componentModule, testCases); + discriminator, imports, componentModule, testCases, refInfo); } } diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index e1f4f83b3c8..d2f10612be2 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -1642,7 +1642,7 @@ public String toInstantiationType(Schema schema) { * * @param codegenParameter Codegen parameter */ - public void setParameterExampleValue(CodegenRequestBody codegenParameter) { + public void setParameterExampleValue(CodegenRequestBodyBase codegenParameter) { // set the example value // if not specified in x-example, generate a default value @@ -2277,7 +2277,7 @@ private CodegenSchema discriminatorFound(String composedSchemaName, Schema sc, S "'{}' defines discriminator '{}', but the referenced OneOf schema '{}' is missing {}", composedSchemaName, discPropName, modelName, discPropName); } - if (cp != null && cp.refClass == null) { + if (cp != null && cp.getRefInfo() == null) { cp = thisCp; continue; } @@ -2300,7 +2300,7 @@ private CodegenSchema discriminatorFound(String composedSchemaName, Schema sc, S "'{}' defines discriminator '{}', but the referenced AnyOf schema '{}' is missing {}", composedSchemaName, discPropName, modelName, discPropName); } - if (cp != null && cp.refClass == null) { + if (cp != null && cp.getRefInfo() == null) { cp = thisCp; continue; } @@ -2752,7 +2752,7 @@ protected boolean isValid(String name) { protected String getImport(String className, CodegenSchema schema) { if (className == null) { - return schema.getRefClass(); + return schema.getRefInfo().getRefClass(); } return className; } @@ -2814,9 +2814,7 @@ private Set getImports(CodegenSchema schema, FeatureSet featureSet) { } } // referenced or inline schemas - String refClass = schema.getRefClass(); - String refModule = schema.getRefModule(); - if (refClass != null && refModule != null) { + if (schema.getRefInfo() != null && schema.getRefInfo().getRefModule() != null) { // self reference classes do not contain refModule imports.add(getImport(null, schema)); } @@ -2891,7 +2889,7 @@ public CodegenSchema fromSchema(Schema p, String sourceJsonPath, String currentJ CodegenSchema property = codegenSchemaCache.computeIfAbsent(ck, s -> new CodegenSchema()); String ref = p.get$ref(); - setLocationInfo(ref, property, currentJsonPath, "schemas", sourceJsonPath); + setSchemaLocationInfo(ref, sourceJsonPath, currentJsonPath, property); if (ref != null) { return property; } @@ -2933,7 +2931,6 @@ public CodegenSchema fromSchema(Schema p, String sourceJsonPath, String currentJ updateModelForComposedSchema(property, p, currentJsonPath); } - property.setComponentModule(toComponentModule(usedName, "schemas")); if (openAPI != null) { HashMap schemaTestCases = extractSchemaTestCases(xSchemaTestExamplesRefPrefix + usedName); property.testCases = schemaTestCases; @@ -3060,6 +3057,9 @@ public CodegenSchema fromSchema(Schema p, String sourceJsonPath, String currentJ } public String toRefClass(String ref, String sourceJsonPath, String expectedComponentType) { + if (ref == null) { + return null; + } String[] refPieces = ref.split("/"); return toModelName(refPieces[refPieces.length-1]); } @@ -3246,8 +3246,8 @@ public CodegenOperation fromOperation(String path, List queryParams = new ArrayList<>(); List headerParams = new ArrayList<>(); List cookieParams = new ArrayList<>(); - List requiredParams = new ArrayList<>(); - List optionalParams = new ArrayList<>(); + List requiredParams = new ArrayList<>(); + List optionalParams = new ArrayList<>(); RequestBody opRequestBody = operation.getRequestBody(); CodegenRequestBody requestBody; @@ -3256,9 +3256,9 @@ public CodegenOperation fromOperation(String path, requestBody = fromRequestBody(opRequestBody, sourceJsonPath + "/requestBody"); op.requestBody = requestBody; - CodegenRequestBody ref = (CodegenRequestBody) requestBody.getRef(); - if (ref != null) { - if (ref.required) { + CodegenRefInfo refInfo = requestBody.getRefInfo(); + if (refInfo != null) { + if (refInfo.getRef().required) { requiredParams.add(requestBody); } else { optionalParams.add(requestBody); @@ -3288,8 +3288,9 @@ public CodegenOperation fromOperation(String path, i++; CodegenParameter paramOrRef = p; - if (p.getRef() != null) { - paramOrRef = (CodegenParameter) p.getRef(); + CodegenRefInfo refInfo = p.getRefInfo(); + if (refInfo != null) { + paramOrRef = refInfo.getRef(); } if (paramOrRef.isQueryParam) { queryParams.add(p); @@ -3308,9 +3309,9 @@ public CodegenOperation fromOperation(String path, // create optional, required parameters for (CodegenParameter cp : allParams) { - CodegenParameter ref = (CodegenParameter) cp.getRef(); - if (ref != null) { - if (ref.required) { //required parameters + CodegenRefInfo refInfo = cp.getRefInfo(); + if (refInfo != null) { + if (refInfo.getRef().required) { //required parameters requiredParams.add(cp); } else { // optional parameters optionalParams.add(cp); @@ -3388,7 +3389,7 @@ public CodegenResponse fromResponse(ApiResponse response, String sourceJsonPath) CodegenResponse r = codegenResponseCache.computeIfAbsent(sourceJsonPath, s -> new CodegenResponse()); String responseRef = response.get$ref(); - setLocationInfo(responseRef, r, sourceJsonPath, "responses", null); + setResponseLocationInfo(responseRef, sourceJsonPath, sourceJsonPath, r); if (responseRef != null) { return r; } @@ -3486,7 +3487,7 @@ public CodegenHeader fromHeader(Header header, String sourceJsonPath) { CodegenHeader codegenHeader = codegenHeaderCache.computeIfAbsent(sourceJsonPath, s -> new CodegenHeader()); String headerRef = header.get$ref(); - setLocationInfo(headerRef, codegenHeader, sourceJsonPath, "headers", null); + setHeaderLocationInfo(headerRef, sourceJsonPath, sourceJsonPath, codegenHeader); if (headerRef != null) { return codegenHeader; } @@ -3499,7 +3500,7 @@ public CodegenHeader fromHeader(Header header, String sourceJsonPath) { return codegenHeader; } - private void setRequestBodyInfo(RequestBody requestBody, CodegenRequestBody codegenRequestBody, String sourceJsonPath) { + private void setRequestBodyInfo(RequestBody requestBody, CodegenRequestBodyBase codegenRequestBody, String sourceJsonPath) { codegenRequestBody.description = escapeText(requestBody.getDescription()); codegenRequestBody.unescapedDescription = requestBody.getDescription(); codegenRequestBody.jsonSchema = Json.pretty(requestBody); @@ -3525,7 +3526,7 @@ private RequestBody toRequestBody(Header header) { return body; } - private void setHeaderInfo(Header header, CodegenHeader codegenHeader, String sourceJsonPath) { + private void setHeaderInfo(Header header, CodegenHeaderBase codegenHeader, String sourceJsonPath) { RequestBody requestBody = toRequestBody(header); setRequestBodyInfo(requestBody, codegenHeader, sourceJsonPath); if (header.getDeprecated() != null) { @@ -3543,7 +3544,7 @@ private void setHeaderInfo(Header header, CodegenHeader codegenHeader, String so usedSourceJsonPath ); codegenHeader.setSchema(prop); - if (prop.getRefModule() != null) { + if (prop.getRefInfo() != null && prop.getRefInfo().getRefModule() != null) { codegenHeader.imports.add(getImport(null, prop)); } } @@ -3584,7 +3585,7 @@ public CodegenParameter fromParameter(Parameter parameter, String sourceJsonPath CodegenParameter codegenParameter = codegenParameterCache.computeIfAbsent(sourceJsonPath, s -> new CodegenParameter()); String parameterRef = parameter.get$ref(); - setLocationInfo(parameterRef, codegenParameter, sourceJsonPath, "parameters", null); + setParameterLocationInfo(parameterRef, sourceJsonPath, sourceJsonPath, codegenParameter); if (parameterRef != null) { return codegenParameter; } @@ -4591,7 +4592,7 @@ public void updateCodegenPropertyEnum(CodegenSchema var) { } Optional referencedSchema = ModelUtils.getSchemas(openAPI).entrySet().stream() - .filter(entry -> Objects.equals(var.refClass, toModelName(entry.getKey()))) + .filter(entry -> Objects.equals(var.getRefInfo().getRefClass(), toModelName(entry.getKey()))) .map(Map.Entry::getValue) .findFirst(); List> enumVars = buildEnumVars(values, var); @@ -4978,7 +4979,7 @@ protected LinkedHashMap getContent(Content content, Se CodegenMediaType codegenMt = new CodegenMediaType(schemaProp, ceMap, schemaTestCases); cmtContent.put(contentType, codegenMt); - if (schemaProp != null && schemaProp.getRefModule() != null) { + if (schemaProp != null && schemaProp.getRefInfo() != null && schemaProp.getRefInfo().getRefModule() != null) { imports.add(getImport(null, schemaProp)); } } @@ -4990,6 +4991,9 @@ public String toRequestBodyFilename(String componentName) { } protected String toRefModule(String ref, String sourceJsonPath, String expectedComponentType) { + if (ref == null) { + return null; + } // ref #/components/schemas/SomeModel -> some_model // ref #/components/requestBodies/SomeBody -> some_body // ref #/components/parameters/SomeParam -> some_param @@ -5024,51 +5028,108 @@ protected String toRefModule(String ref, String sourceJsonPath, String expectedC return null; } - private Object getRef(String ref, String expectedComponentType) { - switch (expectedComponentType) { - case "requestBodies": - return codegenRequestBodyCache.computeIfAbsent(ref, s -> new CodegenRequestBody()); - case "responses": - return codegenResponseCache.computeIfAbsent(ref, s -> new CodegenResponse()); - case "headers": - return codegenHeaderCache.computeIfAbsent(ref, s -> new CodegenHeader()); - case "parameters": - return codegenParameterCache.computeIfAbsent(ref, s -> new CodegenParameter()); - case "schemas": - CodegenSchemaCacheKey ck = new CodegenSchemaCacheKey(ref, ref); - return codegenSchemaCache.computeIfAbsent(ck, s -> new CodegenSchema()); + private CodegenKey getName(String expectedComponentType, String currentJsonPath) { + // last fragment info + // requestBody -> requestBody + // headers -> headerName + // parameters/i -> i + // components/parameters/someParam -> someParam + String usedName; + if (expectedComponentType.equals("schemas")) { + usedName = getUsedName(currentJsonPath); + } else { + usedName = currentJsonPath.substring(currentJsonPath.lastIndexOf("/") + 1); } - return null; + CodegenKey name = getKey(usedName, expectedComponentType); + return name; } - private void setLocationInfo(String ref, OpenApiComponent instance, String currentJsonPath, String expectedComponentType, String sourceJsonPath) { + private void setRequestBodyLocationInfo(String ref, String sourceJsonPath, String currentJsonPath, OpenApiLocation instance) { + String expectedComponentType = "requestBodies"; if (ref != null) { - Object objRef = getRef(ref, expectedComponentType); - instance.setRef(objRef); String refModule = toRefModule(ref, sourceJsonPath, expectedComponentType); - instance.setRefModule(refModule); String refClass = toRefClass(ref, sourceJsonPath, expectedComponentType); - instance.setRefClass(refClass); + CodegenRequestBody rb = codegenRequestBodyCache.computeIfAbsent(ref, s -> new CodegenRequestBody()); + instance.setRefInfo(new CodegenRefInfo<>(rb, refClass, refModule)); } - if (currentJsonPath != null) { - String[] pathPieces = currentJsonPath.split("/"); - if (currentJsonPath.startsWith("#/components/") && pathPieces.length == 4) { - String componentName = pathPieces[3]; - instance.setComponentModule(toComponentModule(componentName, expectedComponentType)); - } - // last fragment info - // requestBody -> requestBody - // headers -> headerName - // parameters/i -> i - // components/parameters/someParam -> someParam - String usedName; - if (expectedComponentType.equals("schemas")) { - usedName = getUsedName(currentJsonPath); - } else { - usedName = currentJsonPath.substring(currentJsonPath.lastIndexOf("/") + 1); - } - CodegenKey name = getKey(usedName, expectedComponentType); - instance.setName(name); + CodegenKey name = getName(expectedComponentType, currentJsonPath); + instance.setName(name); + String[] pathPieces = currentJsonPath.split("/"); + // #/components/requestBodies/A + if (pathPieces.length == 4 && currentJsonPath.startsWith("#/components/"+expectedComponentType+"/")) { + instance.setComponentModule(toComponentModule(pathPieces[3], expectedComponentType)); + } + } + + private void setResponseLocationInfo(String ref, String sourceJsonPath, String currentJsonPath, OpenApiLocation instance) { + String expectedComponentType = "responses"; + if (ref != null) { + String refModule = toRefModule(ref, sourceJsonPath, expectedComponentType); + String refClass = toRefClass(ref, sourceJsonPath, expectedComponentType); + CodegenResponse rb = codegenResponseCache.computeIfAbsent(ref, s -> new CodegenResponse()); + instance.setRefInfo(new CodegenRefInfo<>(rb, refClass, refModule)); + } + CodegenKey name = getName(expectedComponentType, currentJsonPath); + instance.setName(name); + String[] pathPieces = currentJsonPath.split("/"); + // #/components/responses/A + if (pathPieces.length == 4 && currentJsonPath.startsWith("#/components/"+expectedComponentType+"/")) { + instance.setComponentModule(toComponentModule(pathPieces[3], expectedComponentType)); + } + } + + private void setHeaderLocationInfo(String ref, String sourceJsonPath, String currentJsonPath, OpenApiLocation instance) { + String expectedComponentType = "headers"; + if (ref != null) { + String refModule = toRefModule(ref, sourceJsonPath, expectedComponentType); + String refClass = toRefClass(ref, sourceJsonPath, expectedComponentType); + CodegenHeader rb = codegenHeaderCache.computeIfAbsent(ref, s -> new CodegenHeader()); + instance.setRefInfo(new CodegenRefInfo<>(rb, refClass, refModule)); + } + CodegenKey name = getName(expectedComponentType, currentJsonPath); + instance.setName(name); + String[] pathPieces = currentJsonPath.split("/"); + // #/components/headers/A + if (pathPieces.length == 4 && currentJsonPath.startsWith("#/components/"+expectedComponentType+"/")) { + instance.setComponentModule(toComponentModule(pathPieces[3], expectedComponentType)); + } + } + + private void setParameterLocationInfo(String ref, String sourceJsonPath, String currentJsonPath, OpenApiLocation instance) { + String expectedComponentType = "parameters"; + if (ref != null) { + String refModule = toRefModule(ref, sourceJsonPath, expectedComponentType); + String refClass = toRefClass(ref, sourceJsonPath, expectedComponentType); + CodegenParameter rb = codegenParameterCache.computeIfAbsent(ref, s -> new CodegenParameter()); + instance.setRefInfo(new CodegenRefInfo<>(rb, refClass, refModule)); + } + CodegenKey name = getName(expectedComponentType, currentJsonPath); + instance.setName(name); + String[] pathPieces = currentJsonPath.split("/"); + // #/components/parameters/A + if (pathPieces.length == 4 && currentJsonPath.startsWith("#/components/"+expectedComponentType+"/")) { + instance.setComponentModule(toComponentModule(pathPieces[3], expectedComponentType)); + } + } + + private void setSchemaLocationInfo(String ref, String sourceJsonPath, String currentJsonPath, OpenApiLocation instance) { + String expectedComponentType = "schemas"; + if (ref != null) { + String refModule = toRefModule(ref, sourceJsonPath, expectedComponentType); + String refClass = toRefClass(ref, sourceJsonPath, expectedComponentType); + CodegenSchemaCacheKey ck = new CodegenSchemaCacheKey(ref, ref); + CodegenSchema cs = codegenSchemaCache.computeIfAbsent(ck, s -> new CodegenSchema()); + instance.setRefInfo(new CodegenRefInfo<>(cs, refClass, refModule)); + } + if (currentJsonPath == null) { + return; + } + CodegenKey name = getName(expectedComponentType, currentJsonPath); + instance.setName(name); + String[] pathPieces = currentJsonPath.split("/"); + // #/components/schemas/A + if (pathPieces.length == 4 && currentJsonPath.startsWith("#/components/"+expectedComponentType+"/")) { + instance.setComponentModule(toComponentModule(pathPieces[3], expectedComponentType)); } } @@ -5081,7 +5142,7 @@ public CodegenRequestBody fromRequestBody(RequestBody requestBody, String source CodegenRequestBody codegenRequestBody = codegenRequestBodyCache.computeIfAbsent(sourceJsonPath, s -> new CodegenRequestBody()); String bodyRef = requestBody.get$ref(); - setLocationInfo(bodyRef, codegenRequestBody, sourceJsonPath, "requestBodies", null); + setRequestBodyLocationInfo(bodyRef, sourceJsonPath, sourceJsonPath, codegenRequestBody); if (bodyRef != null) { return codegenRequestBody; } diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index fa434279c32..2ac29d0360e 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -521,7 +521,7 @@ void generatePaths(List files, Map> operati if (shouldGenerateApis) { // paths.some_path.post.request_body.py, only written if there is no refModule - if (co.requestBody != null && co.requestBody.getRefModule() == null) { + if (co.requestBody != null && co.requestBody.getRefInfo() == null) { String requestBodyJsonPath = operationJsonPath + "/requestBody"; generateRequestBody(files, co.requestBody, requestBodyJsonPath); } @@ -529,7 +529,7 @@ void generatePaths(List files, Map> operati // paths.some_path.post.parameter_0.py Integer i = 0; for (CodegenParameter cp: co.allParams) { - if (cp.refModule != null) { + if (cp.getRefInfo() != null) { // skip generation of parameter if it refs another location continue; } @@ -544,7 +544,7 @@ void generatePaths(List files, Map> operati // so each inline header should be a module in the response package String code = responseEntry.getKey(); CodegenResponse response = responseEntry.getValue(); - if (response.getRefModule() == null) { + if (response.getRefInfo() == null) { String responseJsonPath = operationJsonPath + "/responses/" + code; generateResponse(files, response, responseJsonPath); } @@ -685,7 +685,7 @@ private void generateResponse(List files, CodegenResponse response, String for (Map.Entry headerInfo: response.getHeaders().entrySet()) { String headerName = headerInfo.getKey(); CodegenHeader header = headerInfo.getValue(); - if (header.refModule == null) { + if (header.getRefInfo() == null) { String headerJsonPath = jsonPath + "/headers/" + headerName; generateHeader(files, header, headerJsonPath); } @@ -696,7 +696,7 @@ private void generateResponse(List files, CodegenResponse response, String String contentType = contentInfo.getKey(); CodegenMediaType codegenMediaType = contentInfo.getValue(); CodegenSchema schema = codegenMediaType.getSchema(); - if (schema != null && schema.getRefModule() == null) { + if (schema != null && schema.getRefInfo() == null) { String schemaJsonPath = jsonPath + "/content/" + ModelUtils.encodeSlashes(contentType) + "/schema"; generateSchema(files, schema, schemaJsonPath); } @@ -775,7 +775,7 @@ private void generateRequestBody(List files, CodegenRequestBody requestBod CodegenMediaType mt = contentInfo.getValue(); CodegenSchema schema = mt.getSchema(); String schemaJsonPath = jsonPath + "/content/" + ModelUtils.encodeSlashes(contentType) + "/schema"; - if (schema != null && schema.getRefModule() == null) { + if (schema != null && schema.getRefInfo() == null) { generateSchema(files, schema, schemaJsonPath); } } @@ -850,7 +850,7 @@ private void generateParameter(List files, CodegenParameter parameter, Str } // schema CodegenSchema schema = parameter.getSetSchema(); - if (schema != null && schema.getRefModule() == null) { + if (schema != null && schema.getRefInfo() == null) { String schemaJsonPath = parameter.getSetSchemaJsonPath(jsonPath); generateSchema(files, schema, schemaJsonPath); } @@ -921,7 +921,7 @@ private void generateHeader(List files, CodegenHeader header, String jsonP } // schema CodegenSchema schema = header.getSetSchema(); - if (schema != null && schema.getRefModule() == null) { + if (schema != null && schema.getRefInfo() == null) { String schemaJsonPath = header.getSetSchemaJsonPath(jsonPath); generateSchema(files, schema, schemaJsonPath); } diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiComponent.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiLocation.java similarity index 68% rename from modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiComponent.java rename to modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiLocation.java index 7ebfabf0855..b8c939c4a08 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiComponent.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiLocation.java @@ -1,11 +1,17 @@ package org.openapitools.codegen; -public interface OpenApiComponent { +public interface OpenApiLocation { + // stores location info about a jsonPath location + // set only if the instance is at the json path of a component String getComponentModule(); void setComponentModule(String componentModule); + CodegenRefInfo getRefInfo(); + + void setRefInfo(CodegenRefInfo refInfo); + // always set // used for spec name (name.getName) // module name (name.getSnakeCaseName) @@ -15,15 +21,4 @@ public interface OpenApiComponent { void setName(CodegenKey name); - Object getRef(); - - void setRef(Object ref); - - String getRefModule(); - - void setRefModule(String refModule); - - String getRefClass(); - - void setRefClass(String refClass); } diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiSchema.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiSchema.java index ddc288c72f6..96f4cda1472 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiSchema.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/OpenApiSchema.java @@ -159,13 +159,9 @@ public interface OpenApiSchema { void setIsAnyType(boolean isAnyType); - Object getRef(); + CodegenRefInfo getRefInfo(); - void setRef(Object ref); - - String getRefModule(); - - void setRefModule(String ref); + void setRefInfo(CodegenRefInfo refInfo); List getAllOf(); @@ -273,7 +269,4 @@ default void setTypeProperties(Schema p) { setIsAnyType(true); } } - - - String getRefClass(); } diff --git a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index ac75cddff17..3d8a38ec720 100644 --- a/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -751,7 +751,7 @@ public CodegenSchema fromSchema(Schema p, String sourceJsonPath, String currentJ if (cp.isAnyType && cp.isNullable) { cp.isNullable = false; } - if (cp.isNullable && cp.refClass == null) { + if (cp.isNullable && cp.getRefInfo() == null) { cp.setIsNull(true); cp.isNullable = false; cp.setHasMultipleTypes(true); @@ -1997,7 +1997,7 @@ public Map postProcessSupportingFileData(Map obj @Override protected String getImport(String className, CodegenSchema schema) { if (className == null) { - return "from " + packageName() + ".components.schema import " + schema.getRefModule(); + return "from " + packageName() + ".components.schema import " + schema.getRefInfo().getRefModule(); } String[] classPieces = className.split("\\."); return "from " + packageName() + ".components.schema import " + classPieces[0]; @@ -2126,6 +2126,9 @@ private String toParameterRefClass(String ref, String sourceJsonPath) { @Override public String toRefClass(String ref, String sourceJsonPath, String expectedComponentType) { + if (ref == null) { + return null; + } switch (expectedComponentType) { case "schemas": return toSchemaRefClass(ref, sourceJsonPath); @@ -2144,7 +2147,7 @@ public String toRefClass(String ref, String sourceJsonPath, String expectedCompo @Override public void postProcess() { System.out.println("################################################################################"); - System.out.println("# Thanks for using OpenAPI JSON Schema Generator. #"); + System.out.println("# Thanks for using OpenAPI JSON Schema Generator. #"); System.out.println("# Please consider donation to help us maintain this project \uD83D\uDE4F #"); System.out.println("# https://github.com/sponsors/spacether #"); System.out.println("# #"); diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/api_doc_schema_type_hint.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/api_doc_schema_type_hint.handlebars index ed07f68df59..607a1c54208 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/api_doc_schema_type_hint.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/api_doc_schema_type_hint.handlebars @@ -1,8 +1,8 @@ # {{#if schemaNamePrefix1}}{{#if anchorContainsPeriod}}{{/if}}{{> api_doc_schema_fancy_schema_name }}{{#if anchorContainsPeriod}}{{/if}}{{else}}{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}{{/if}} -{{#if refClass}} +{{#if refInfo.refClass}} Type | Description | Notes ------------- | ------------- | ------------- -[**{{refClass}}**]({{complexTypePrefix}}{{> refclass_with_module }}.md) | {{#if description}}{{description}}{{/if}} | {{#if isReadOnly}}[readonly] {{/if}} +[**{{refInfo.refClass}}**]({{complexTypePrefix}}{{> refclass_with_module }}.md) | {{#if description}}{{description}}{{/if}} | {{#if isReadOnly}}[readonly] {{/if}} {{else}} {{> schema_doc }} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint.handlebars index cb6f8090833..6ed30ab8296 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint.handlebars @@ -16,20 +16,20 @@ from {{packageName}} import api_client, exceptions {{> model_templates/imports }} {{#with operation}} {{#with requestBody}} -{{#if refModule}} -from {{packageName}}.components.request_bodies import {{refModule}} as request_body +{{#if refInfo.refModule}} +from {{packageName}}.components.request_bodies import {{refInfo.refModule}} as request_body {{/if}} {{/with}} {{#each responses}} {{#with this}} -{{#if refModule}} -from {{packageName}}.components.responses import {{refModule}} as response_for_{{@key}} +{{#if refInfo.refModule}} +from {{packageName}}.components.responses import {{refInfo.refModule}} as response_for_{{@key}} {{/if}} {{/with}} {{/each}} {{#each allParams}} -{{#if refModule}} -from {{packageName}}.components.parameters import {{refModule}} +{{#if refInfo.refModule}} +from {{packageName}}.components.parameters import {{refInfo.refModule}} {{/if}} {{/each}} @@ -37,17 +37,17 @@ from {{packageName}}.components.parameters import {{refModule}} from .. import path {{/unless}} {{#each responses}} -{{#unless refModule}} +{{#unless refInfo.refModule}} from . import response_for_{{@key}} {{/unless}} {{/each}} {{#with requestBody}} -{{#unless refModule}} +{{#unless refInfo.refModule}} from . import request_body {{/unless}} {{/with}} {{#each allParams}} -{{#unless refModule}} +{{#unless refInfo.refModule}} from . import {{name.getSnakeCaseName}} {{/unless}} {{/each}} @@ -117,7 +117,7 @@ _servers = ( {{#if defaultResponse}} {{#with defaultResponse}} -default_response = response_for_default.{{#if refClass}}{{refClass}}{{else}}{{name.getCamelCaseName}}{{/if}} +default_response = response_for_default.{{#if refInfo.refClass}}{{refInfo.refClass}}{{else}}{{name.getCamelCaseName}}{{/if}} {{/with}} {{/if}} {{#if nonDefaultResponses}} @@ -125,13 +125,13 @@ __StatusCodeToResponse = typing_extensions.TypedDict( '__StatusCodeToResponse', { {{#each nonDefaultResponses}} - '{{@key}}': response_for_{{@key}}.{{#if refClass}}{{refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}, + '{{@key}}': response_for_{{@key}}.{{#if refInfo.refClass}}{{refInfo.refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}, {{/each}} } ) _status_code_to_response = __StatusCodeToResponse({ {{#each nonDefaultResponses}} - '{{@key}}': response_for_{{@key}}.{{#if refClass}}{{refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}, + '{{@key}}': response_for_{{@key}}.{{#if refInfo.refClass}}{{refInfo.refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}, {{/each}} }) {{/if}} @@ -239,8 +239,8 @@ class BaseApi(api_client.Api): {{/if}} {{#with requestBody}} - {{#if ref}} - {{#if ref.required}} + {{#if refInfo}} + {{#if refInfo.getRef.required}} if body is schemas.unset: raise exceptions.ApiValueError( 'The required body parameter has an invalid value of: unset. Set a valid value instead') @@ -254,8 +254,8 @@ class BaseApi(api_client.Api): {{/if}} _fields = None _body = None - {{#if ref}} - {{#if ref.required}} + {{#if refInfo}} + {{#if refInfo.getRef.required}} {{> endpoint_body_serialization }} {{else}} if body is not schemas.unset: diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_args_passed.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_args_passed.handlebars index 26fa1f89513..c69e5911c24 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_args_passed.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_args_passed.handlebars @@ -16,8 +16,8 @@ path_params=path_params, cookie_params=cookie_params, {{/if}} {{#with requestBody}} - {{#if ref}} - {{#each ref.content}} + {{#if refInfo}} + {{#each refInfo.getRef.content}} {{#if @first}} content_type=content_type, {{/if}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_args_request_body.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_args_request_body.handlebars index 1533ba2fc98..3d6a47935e4 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_args_request_body.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_args_request_body.handlebars @@ -1,10 +1,10 @@ -{{#if requestBody.ref}} - {{#if requestBody.ref.required}} - {{#with requestBody.ref}} +{{#if requestBody.refInfo}} + {{#if requestBody.refInfo.getRef.required}} + {{#with requestBody.refInfo.getRef}} {{#eq ../contentType "null"}} - body: typing.Union[{{#each getContent}}{{#with this.schema}}request_body.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}},{{> model_templates/schema_python_types }}{{/with}}{{/each}}], + body: typing.Union[{{#each getContent}}{{#with this.schema}}request_body.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}},{{> model_templates/schema_python_types }}{{/with}}{{/each}}], {{else}} - body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}request_body.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}},{{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}], + body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}request_body.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}},{{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}], {{/eq}} {{/with}} {{#if isOverload}} @@ -12,7 +12,7 @@ skip_deserialization: typing_extensions.Literal[True], {{/eq}} {{#neq contentType "null"}} - {{#with requestBody.ref}} + {{#with requestBody.refInfo.getRef}} {{#each content}} {{#eq @key ../../contentType}} {{#if @first}} @@ -27,7 +27,7 @@ content_type: str = ..., {{/neq}} {{else}} - {{#with requestBody.ref}} + {{#with requestBody.refInfo.getRef}} {{#each getContent}} {{#if @first}} content_type: str = '{{{@key}}}', @@ -41,7 +41,7 @@ skip_deserialization: typing_extensions.Literal[True], {{/eq}} {{#neq contentType "null"}} - {{#with requestBody.ref}} + {{#with requestBody.refInfo.getRef}} {{#each getContent}} {{#eq @key ../../contentType}} {{#if @first}} @@ -56,7 +56,7 @@ content_type: str = ..., {{/neq}} {{else}} - {{#with requestBody.ref}} + {{#with requestBody.refInfo.getRef}} {{#each getContent}} {{#if @first}} content_type: str = '{{{@key}}}', @@ -64,11 +64,11 @@ {{/each}} {{/with}} {{/if}} - {{#with requestBody.ref}} + {{#with requestBody.refInfo.retRef}} {{#eq ../contentType "null"}} - body: typing.Union[{{#each getContent}}{{#with this.schema}}request_body.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}{{/with}}{{/each}}schemas.Unset] = schemas.unset, + body: typing.Union[{{#each getContent}}{{#with this.schema}}request_body.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}{{/with}}{{/each}}schemas.Unset] = schemas.unset, {{else}} - body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}request_body.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}schemas.Unset] = schemas.unset, + body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}request_body.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}schemas.Unset] = schemas.unset, {{/eq}} {{/with}} {{/if}} @@ -76,9 +76,9 @@ {{#if requestBody.required}} {{#with requestBody}} {{#eq ../contentType "null"}} - body: typing.Union[{{#each getContent}}{{#with this.schema}}request_body.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}},{{> model_templates/schema_python_types }}{{/with}}{{/each}}], + body: typing.Union[{{#each getContent}}{{#with this.schema}}request_body.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}},{{> model_templates/schema_python_types }}{{/with}}{{/each}}], {{else}} - body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}request_body.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}},{{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}], + body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}request_body.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}},{{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}], {{/eq}} {{/with}} {{#if isOverload}} @@ -140,9 +140,9 @@ {{/if}} {{#with requestBody}} {{#eq ../contentType "null"}} - body: typing.Union[{{#each getContent}}{{#with this.schema}}request_body.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}{{/with}}{{/each}}schemas.Unset] = schemas.unset, + body: typing.Union[{{#each getContent}}{{#with this.schema}}request_body.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}{{/with}}{{/each}}schemas.Unset] = schemas.unset, {{else}} - body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}request_body.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}schemas.Unset] = schemas.unset, + body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}request_body.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}schemas.Unset] = schemas.unset, {{/eq}} {{/with}} {{/if}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_body_serialization.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_body_serialization.handlebars index f525bfe5d9e..d5a49329619 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_body_serialization.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_body_serialization.handlebars @@ -1,4 +1,4 @@ -serialized_data = request_body.{{#if refClass}}{{refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}.serialize(body, content_type) +serialized_data = request_body.{{#if refInfo.refClass}}{{refInfo.refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}.serialize(body, content_type) _headers.add('Content-Type', content_type) if 'fields' in serialized_data: _fields = serialized_data['fields'] diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_doc.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_doc.handlebars index a293c3230f2..d29d5ed75be 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_doc.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_doc.handlebars @@ -38,8 +38,8 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- {{#with requestBody}} - {{#if refModule}} -[**body**](../../../components/request_bodies/{{refModule}}.md) | typing.Union[{{#each ref.content}}{{#unless @first}}, {{/unless}}{{#with this.schema}}[request_body.{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](../../../components/request_bodies/{{../refModule}}.md#{{packageName}}.components.request_bodies.{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/with}}{{/each}}{{#unless ref.required}}, Unset]{{else}}]{{/unless}} | {{#if ref.required}}required{{else}}optional, default is unset{{/if}} | + {{#if refInfo.refModule}} +[**body**](../../../components/request_bodies/{{refInfo.refModule}}.md) | typing.Union[{{#each refInfo.getRef.content}}{{#unless @first}}, {{/unless}}{{#with this.schema}}[request_body.{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](../../../components/request_bodies/{{../refInfo.refModule}}.md#{{packageName}}.components.request_bodies.{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/with}}{{/each}}{{#unless refInfo.getRef.required}}, Unset]{{else}}]{{/unless}} | {{#if refInfo.getRef.required}}required{{else}}optional, default is unset{{/if}} | {{else}} [body](#request_body) | typing.Union[{{#each content}}{{#unless @first}}, {{/unless}}{{#with this.schema}}[request_body.{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](#request_body.{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/with}}{{/each}}{{#unless required}}, Unset]{{else}}]{{/unless}} | {{#if required}}required{{else}}optional, default is unset{{/if}} | {{/if}} @@ -57,8 +57,8 @@ Name | Type | Description | Notes [cookie_params](#RequestCookieParameters) | [RequestCookieParameters.Params](#RequestCookieParameters.Params) | | {{/if}} {{#with requestBody}} - {{#if ref}} - {{#each ref.content}} + {{#if refInfo}} + {{#each refInfo.getRef.content}} {{#if @first}} content_type | str | optional, default is '{{@key}}' | Selects the schema and serialization of the request body {{/if}} @@ -81,7 +81,7 @@ stream | bool | default is False | if True then the response.content will be str 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 {{#if requestBody}} - {{#unless requestBody.refModule}} + {{#unless requestBody.refInfo.refModule}} ### body {{> request_body_doc requestBody=requestBody schemaNamePrefix1="request_body" }} @@ -95,15 +95,15 @@ skip_deserialization | bool | default is False | when True, headers and body wil Key | Input Type | Description | Notes ------------- | ------------- | ------------- | ------------- {{#each queryParams}} - {{#if refModule}} -{{ref.baseName}} | [{{refModule}}.schema](../../../components/parameters/{{refModule}}.md) | | {{#unless ref.required}}optional{{/unless}} + {{#if refInfo.refModule}} +{{refInfo.getRef.baseName}} | [{{refInfo.refModule}}.schema](../../../components/parameters/{{refInfo.refModule}}.md) | | {{#unless refInfo.getRef.required}}optional{{/unless}} {{else}} {{baseName}} | [{{name.getSnakeCaseName}}.schema](#{{name.getSnakeCaseName}}.schema) | | {{#unless required}}optional{{/unless}} {{/if}} {{/each}} {{#each queryParams as | parameter |}} - {{#unless parameter.refModule}} + {{#unless parameter.refInfo.refModule}} {{> parameter_doc complexTypePrefix="../../../components/schema/" }} {{/unless}} @@ -117,14 +117,14 @@ Key | Input Type | Description | Notes Key | Input Type | Description | Notes ------------- | ------------- | ------------- | ------------- {{#each headerParams}} - {{#if refModule}} -{{ref.baseName}} | [{{refModule}}.schema](../../../components/parameters/{{refModule}}.md) | | {{#unless ref.required}}optional{{/unless}} + {{#if refInfo.refModule}} +{{refInfo.getRef.baseName}} | [{{refInfo.refModule}}.schema](../../../components/parameters/{{refInfo.refModule}}.md) | | {{#unless refInfo.getRef.required}}optional{{/unless}} {{else}} {{baseName}} | [{{name.getSnakeCaseName}}.schema](#{{name.getSnakeCaseName}}.schema) | | {{#unless required}}optional{{/unless}} {{/if}} {{/each}} {{#each headerParams as | parameter |}} - {{#unless parameter.refModule}} + {{#unless parameter.refInfo.refModule}} {{> parameter_doc complexTypePrefix="../../../components/schema/" }} {{/unless}} @@ -138,14 +138,14 @@ Key | Input Type | Description | Notes Key | Input Type | Description | Notes ------------- | ------------- | ------------- | ------------- {{#each pathParams}} - {{#if refModule}} -{{ref.baseName}} | [{{refModule}}.schema](../../../components/parameters/{{refModule}}.md) | | {{#unless ref.required}}optional{{/unless}} + {{#if refInfo.refModule}} +{{refInfo.getRef.baseName}} | [{{refInfo.refModule}}.schema](../../../components/parameters/{{refInfo.refModule}}.md) | | {{#unless refInfo.getRef.required}}optional{{/unless}} {{else}} {{baseName}} | [{{name.getSnakeCaseName}}.schema](#{{name.getSnakeCaseName}}.schema) | | {{#unless required}}optional{{/unless}} {{/if}} {{/each}} {{#each pathParams as | parameter |}} - {{#unless parameter.refModule}} + {{#unless parameter.refInfo.refModule}} {{> parameter_doc complexTypePrefix="../../../components/schema/" }} {{/unless}} @@ -159,14 +159,14 @@ Key | Input Type | Description | Notes Key | Input Type | Description | Notes ------------- | ------------- | ------------- | ------------- {{#each cookieParams}} - {{#if refModule}} -{{ref.baseName}} | [{{refModule}}.schema](../../../components/parameters/{{refModule}}.md) | | {{#unless ref.required}}optional{{/unless}} + {{#if refInfo.refModule}} +{{refInfo.getRef.baseName}} | [{{refInfo.refModule}}.schema](../../../components/parameters/{{refInfo.refModule}}.md) | | {{#unless refInfo.getRef.required}}optional{{/unless}} {{else}} {{baseName}} | [{{name.getSnakeCaseName}}.schema](#{{name.getSnakeCaseName}}.schema) | | {{#unless required}}optional{{/unless}} {{/if}} {{/each}} {{#each cookieParams as | parameter |}} - {{#unless parameter.refModule}} + {{#unless parameter.refInfo.refModule}} {{> parameter_doc complexTypePrefix="../../../components/schema/" }} {{/unless}} @@ -183,22 +183,22 @@ Code | Class | Description n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned {{#if defaultResponse}} {{#with defaultResponse}} -{{#if refModule}} -default | [{{refModule}}.ApiResponse](../../../components/responses/{{refModule}}.md) | {{#with ref}}{{message}}{{/with}} +{{#if refInfo.refModule}} +default | [{{refInfo.refModule}}.ApiResponse](../../../components/responses/{{refInfo.refModule}}.md) | {{#with refInfo.getRef}}{{message}}{{/with}} {{else}} default | [response_for_default.ApiResponse](#response_for_default.ApiResponse) | {{message}} {{/if}} {{/with}} {{/if}} {{#each nonDefaultResponses}} -{{#if refModule}} -{{@key}} | [{{refModule}}.ApiResponse](../../../components/responses/{{refModule}}.md) | {{#with ref}}{{message}}{{/with}} +{{#if refInfo.refModule}} +{{@key}} | [{{refInfo.refModule}}.ApiResponse](../../../components/responses/{{refInfo.refModule}}.md) | {{#with refInfo.getRef}}{{message}}{{/with}} {{else}} {{@key}} | [response_for_{{@key}}.ApiResponse](#response_for_{{@key}}.ApiResponse) | {{message}} {{/if}} {{/each}} {{#each responses}} -{{#unless refModule}} +{{#unless refInfo.refModule}} {{> response_doc response=this complexTypePrefix="../../../components/schema/" }} {{/unless}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_doc_example.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_doc_example.handlebars index f1879461879..4496a1c476b 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_doc_example.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_doc_example.handlebars @@ -32,9 +32,9 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: {{#if pathParams}} path_params = { {{#each pathParams}} - {{#if ref}} - {{#if ref.required}} - '{{ref.baseName}}': {{{ref.example}}}, + {{#if refInfo}} + {{#if refInfo.getRef.required}} + '{{refInfo.getRef.baseName}}': {{{refInfo.getRef.example}}}, {{/if}} {{else}} {{#if required}} @@ -47,9 +47,9 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: {{#if queryParams}} query_params = { {{#each queryParams}} - {{#if ref}} - {{#if ref.required}} - '{{ref.baseName}}': {{{ref.example}}}, + {{#if refInfo}} + {{#if refInfo.getRef.required}} + '{{refInfo.getRef.baseName}}': {{{refInfo.getRef.example}}}, {{/if}} {{else}} {{#if required}} @@ -62,9 +62,9 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: {{#if cookieParams}} cookie_params = { {{#each cookieParams}} - {{#if ref}} - {{#if ref.required}} - '{{ref.baseName}}': {{{ref.example}}}, + {{#if refInfo}} + {{#if refInfo.getRef.required}} + '{{refInfo.getRef.baseName}}': {{{refInfo.getRef.example}}}, {{/if}} {{else}} {{#if required}} @@ -77,9 +77,9 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: {{#if headerParams}} header_params = { {{#each headerParams}} - {{#if ref}} - {{#if ref.required}} - '{{ref.baseName}}': {{{ref.example}}}, + {{#if refInfo}} + {{#if refInfo.getRef.required}} + '{{refInfo.getRef.baseName}}': {{{refInfo.getRef.example}}}, {{/if}} {{else}} {{#if required}} @@ -90,9 +90,9 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: } {{/if}} {{#with requestBody}} - {{#if ref}} - {{#if ref.required}} - body = {{{ref.example}}} + {{#if refInfo}} + {{#if refInfo.getRef.required}} + body = {{{refInfo.getRef.example}}} {{/if}} {{else}} {{#if required}} @@ -118,8 +118,8 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: cookie_params=cookie_params, {{/if}} {{#with requestBody}} - {{#if ref}} - {{#if ref.required}} + {{#if refInfo}} + {{#if refInfo.getRef.required}} body=body, {{/if}} {{else}} @@ -147,8 +147,8 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: {{#if pathParams}} path_params = { {{#each pathParams}} - {{#if ref}} - '{{ref.baseName}}': {{{ref.example}}}, + {{#if refInfo}} + '{{refInfo.getRef.baseName}}': {{{refInfo.getRef.example}}}, {{else}} '{{baseName}}': {{{example}}}, {{/if}} @@ -158,8 +158,8 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: {{#if queryParams}} query_params = { {{#each queryParams}} - {{#if ref}} - '{{ref.baseName}}': {{{ref.example}}}, + {{#if refInfo}} + '{{refInfo.getRef.baseName}}': {{{refInfo.getRef.example}}}, {{else}} '{{baseName}}': {{{example}}}, {{/if}} @@ -169,8 +169,8 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: {{#if cookieParams}} cookie_params = { {{#each cookieParams}} - {{#if ref}} - '{{ref.baseName}}': {{{ref.example}}}, + {{#if refInfo}} + '{{refInfo.getRef.baseName}}': {{{refInfo.getRef.example}}}, {{else}} '{{baseName}}': {{{example}}}, {{/if}} @@ -180,8 +180,8 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: {{#if headerParams}} header_params = { {{#each headerParams}} - {{#if ref}} - '{{ref.baseName}}': {{{ref.example}}}, + {{#if refInfo}} + '{{refInfo.getRef.baseName}}': {{{refInfo.getRef.example}}}, {{else}} '{{baseName}}': {{{example}}}, {{/if}} @@ -189,8 +189,8 @@ with {{{packageName}}}.ApiClient(configuration) as api_client: } {{/if}} {{#with requestBody}} - {{#if ref}} - body = {{{ref.example}}} + {{#if refInfo}} + body = {{{refInfo.getRef.example}}} {{else}} body = {{{example}}} {{/if}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_parameter_schema_and_def.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_parameter_schema_and_def.handlebars index fe476225982..09a37205bc1 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_parameter_schema_and_def.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_parameter_schema_and_def.handlebars @@ -5,20 +5,20 @@ class {{xParamsName}}: 'RequiredParams', { {{#each xParams}} -{{#if ref}} - {{#if ref.required}} - {{#if ref.schema}} - '{{ref.baseName}}': {{#with ref.schema}}typing.Union[{{#if ../refModule}}{{../refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}} +{{#if refInfo}} + {{#if refInfo.getRef.required}} + {{#if refInfo.getRef.schema}} + '{{refInfo.getRef.baseName}}': {{#with refInfo.getRef.schema}}typing.Union[{{#if ../refInfo.refModule}}{{../refInfo.refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}} {{else}} - '{{ref.baseName}}': {{#each ref.getContent}}{{#with this}}{{#with schema}}typing.Union[{{#if ../refModule}}{{../refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}} + '{{refInfo.getRef.baseName}}': {{#each refInfo.getRef.getContent}}{{#with this}}{{#with schema}}typing.Union[{{#if ../refInfo.refModule}}{{../refInfo.refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}} {{/if}} {{/if}} {{else}} {{#if required}} {{#if schema}} - '{{baseName}}': {{#with schema}}typing.Union[{{#if ../refModule}}{{../refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}} + '{{baseName}}': {{#with schema}}typing.Union[{{#if ../refInfo.refModule}}{{../refInfo.refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}} {{else}} - '{{baseName}}': {{#each getContent}}{{#with this}}{{#with schema}}typing.Union[{{#if ../refModule}}{{../refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}} + '{{baseName}}': {{#each getContent}}{{#with this}}{{#with schema}}typing.Union[{{#if ../refInfo.refModule}}{{../refInfo.refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}} {{/if}} {{/if}} {{/if}} @@ -29,20 +29,20 @@ class {{xParamsName}}: 'OptionalParams', { {{#each xParams}} -{{#if ref}} - {{#unless ref.required}} - {{#if ref.schema}} - '{{ref.baseName}}': {{#with ref.schema}}typing.Union[{{#if ../refModule}}{{../refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}} +{{#if refInfo}} + {{#unless refInfo.getRef.required}} + {{#if refInfo.getRef.schema}} + '{{refInfo.getRef.baseName}}': {{#with refInfo.getRef.schema}}typing.Union[{{#if ../refInfo.refModule}}{{../refInfo.refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}} {{else}} - '{{ref.baseName}}': {{#each ref.getContent}}{{#with this}}{{#with schema}}typing.Union[{{#if ../refModule}}{{../refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}} + '{{refInfo.getRef.baseName}}': {{#each refInfo.getRef.getContent}}{{#with this}}{{#with schema}}typing.Union[{{#if ../refInfo.refModule}}{{../refInfo.refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}} {{/if}} {{/unless}} {{else}} {{#unless required}} {{#if schema}} - '{{baseName}}': {{#with schema}}typing.Union[{{#if ../refModule}}{{../refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}} + '{{baseName}}': {{#with schema}}typing.Union[{{#if ../refInfo.refModule}}{{../refInfo.refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}} {{else}} - '{{baseName}}': {{#each getContent}}{{#with this}}{{#with schema}}typing.Union[{{#if ../refModule}}{{../refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}} + '{{baseName}}': {{#each getContent}}{{#with this}}{{#with schema}}typing.Union[{{#if ../refInfo.refModule}}{{../refInfo.refModule}}{{else}}{{../name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}} {{/if}} {{/unless}} {{/if}} @@ -58,6 +58,6 @@ class {{xParamsName}}: parameters = [ {{#each xParams}} - {{#if refModule}}{{refModule}}{{else}}{{name.getSnakeCaseName}}{{/if}}.{{#if refClass}}{{refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}, + {{#if refInfo.refModule}}{{refInfo.refModule}}{{else}}{{name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refClass}}{{refInfo.refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}, {{/each}} ] \ No newline at end of file diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_test.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_test.handlebars index 9c2e5e06556..81c1ca72398 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_test.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_test.handlebars @@ -34,8 +34,8 @@ class Test{{operationIdSnakeCase}}(ApiTestMixin, unittest.TestCase): {{#each responses}} {{#if @first}} response_status = {{#eq @key "default"}}0{{else}}{{@key}}{{/eq}} - {{#if ref}} - {{#with ref}} + {{#if refInfo}} + {{#with refInfo.getRef}} {{> endpoint_test_response_content }} {{/with}} {{else}} @@ -61,7 +61,7 @@ class Test{{operationIdSnakeCase}}(ApiTestMixin, unittest.TestCase): {{/with}} ) {{#if valid}} - body = {{httpMethod}}.request_body.{{#with schema}}{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}{{/with}}.from_openapi_data_( + body = {{httpMethod}}.request_body.{{#with schema}}{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}{{/with}}.from_openapi_data_( payload, configuration_=self.configuration_ ) @@ -75,7 +75,7 @@ class Test{{operationIdSnakeCase}}(ApiTestMixin, unittest.TestCase): assert isinstance(api_response.body, schemas.Unset) {{else}} with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError)): - body = {{httpMethod}}.request_body.{{#with schema}}{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}{{/with}}.from_openapi_data_( + body = {{httpMethod}}.request_body.{{#with schema}}{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}{{/with}}.from_openapi_data_( payload, configuration_=self.configuration_ ) diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_test_response_content.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_test_response_content.handlebars index 442c1370d26..24041c7f90e 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_test_response_content.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/endpoint_test_response_content.handlebars @@ -1,7 +1,7 @@ {{#if content}} {{#each content}} {{#if schema}} -response_body_schema = {{httpMethod}}.response_for_{{../@key}}.{{#with schema}}{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}{{/with}} +response_body_schema = {{httpMethod}}.response_for_{{../@key}}.{{#with schema}}{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}{{/with}} {{/if}} {{#if this.testCases}} {{#each testCases}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/header.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/header.handlebars index ec78f9ffb43..c588255fe92 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/header.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/header.handlebars @@ -11,7 +11,7 @@ from {{packageName}} import api_client, exceptions {{> model_templates/imports }} {{#if schema}} {{#with schema}} - {{#unless getRefModule}} + {{#unless refInfo.getRefModule}} from . import {{name.getSnakeCaseName}} {{/unless}} {{/with}} @@ -20,7 +20,7 @@ from . import {{name.getSnakeCaseName}} {{#each getContent}} {{#with this}} {{#with schema}} - {{#unless getRefModule}} + {{#unless refInfo.getRefModule}} from . import {{name.getSnakeCaseName}} {{/unless}} {{/with}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/header_doc.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/header_doc.handlebars index 96679f1f3c5..f9d184495e3 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/header_doc.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/header_doc.handlebars @@ -1,7 +1,7 @@ {{#if componentModule}} {{#each headers}} {{#with this}} - {{#unless refModule}} + {{#unless refInfo.refModule}} {{#if schema}} {{#with schema}} @@ -42,7 +42,7 @@ [[Back to top]](#top) {{> footer_links readmePath="../../../" headersLink=true }} {{else}} - {{#unless refModule}} + {{#unless refInfo.refModule}} {{#if schema}} {{#with schema}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/composed_schemas.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/composed_schemas.handlebars index d8c675c0963..197dbdd3af0 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/composed_schemas.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/composed_schemas.handlebars @@ -2,7 +2,7 @@ class AllOf: {{#each allOf}} -{{#if refClass}} +{{#if refInfo.refClass}} {{> model_templates/refClassStaticmethod }} {{else}} @@ -11,7 +11,7 @@ class AllOf: {{/each}} classes = [ {{#each allOf}} - {{#if refClass}} + {{#if refInfo.refClass}} {{name.getSnakeCaseName}}, {{else}} {{name.getCamelCaseName}}, @@ -23,7 +23,7 @@ class AllOf: class OneOf: {{#each oneOf}} -{{#if refClass}} +{{#if refInfo.refClass}} {{> model_templates/refClassStaticmethod }} {{else}} @@ -32,7 +32,7 @@ class OneOf: {{/each}} classes = [ {{#each oneOf}} - {{#if refClass}} + {{#if refInfo.refClass}} {{name.getSnakeCaseName}}, {{else}} {{name.getCamelCaseName}}, @@ -44,7 +44,7 @@ class OneOf: class AnyOf: {{#each anyOf}} -{{#if refClass}} +{{#if refInfo.refClass}} {{> model_templates/refClassStaticmethod }} {{else}} @@ -53,7 +53,7 @@ class AnyOf: {{/each}} classes = [ {{#each anyOf}} - {{#if refClass}} + {{#if refInfo.refClass}} {{name.getSnakeCaseName}}, {{else}} {{name.getCamelCaseName}}, @@ -63,7 +63,7 @@ class AnyOf: {{/if}} {{#if not}} {{#with not}} -{{#if refClass}} +{{#if refInfo.refClass}} {{> model_templates/refClassStaticmethod }} {{else}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/dict_partial.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/dict_partial.handlebars index a9c58d87107..4e6fe96a50d 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/dict_partial.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/dict_partial.handlebars @@ -27,7 +27,7 @@ def discriminator(): class Properties: {{#each properties}} -{{#if refClass}} +{{#if refInfo.refClass}} {{> model_templates/refClassStaticmethod }} {{else}} @@ -36,7 +36,7 @@ class Properties: {{/each}} __annotations__ = { {{#each properties}} -{{#if refClass}} +{{#if refInfo.refClass}} "{{{@key.getName}}}": {{name.getSnakeCaseName}}, {{else}} "{{{@key.getName}}}": {{name.getCamelCaseName}}, @@ -45,7 +45,7 @@ class Properties: } {{/if}} {{#with additionalProperties}} -{{#if refClass}} +{{#if refInfo.refClass}} {{> model_templates/refClassStaticmethod }} {{else}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/list_partial.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/list_partial.handlebars index b59d95f8215..a8cb8f9080e 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/list_partial.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/list_partial.handlebars @@ -1,5 +1,5 @@ {{#with items}} -{{#if refClass}} +{{#if refInfo.refClass}} {{> model_templates/refClassStaticmethod }} {{else}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/new.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/new.handlebars index abc6fdbb693..1b3c266b7d0 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/new.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/new.handlebars @@ -4,7 +4,7 @@ def __new__( *args_: typing.Union[{{> model_templates/schema_python_types }}], {{else}} {{#if isArray }} - arg_: typing.Union[typing.Tuple[{{#with items}}{{#if refClass}}'{{> refclass_with_module }}'{{else}}typing.Union[Schema_.{{name.getCamelCaseName}}, {{> model_templates/schema_python_types }}]{{/if}}{{/with}}], typing.List[{{#with items}}{{#if refClass}}'{{> refclass_with_module }}'{{else}}typing.Union[Schema_.{{name.getCamelCaseName}}, {{> model_templates/schema_python_types }}]{{/if}}{{/with}}]], + arg_: typing.Union[typing.Tuple[{{#with items}}{{#if refInfo.refClass}}'{{> refclass_with_module }}'{{else}}typing.Union[Schema_.{{name.getCamelCaseName}}, {{> model_templates/schema_python_types }}]{{/if}}{{/with}}], typing.List[{{#with items}}{{#if refInfo.refClass}}'{{> refclass_with_module }}'{{else}}typing.Union[Schema_.{{name.getCamelCaseName}}, {{> model_templates/schema_python_types }}]{{/if}}{{/with}}]], {{else}} *args_: typing.Union[{{> model_templates/schema_python_types }}], {{/if}} @@ -14,7 +14,7 @@ def __new__( {{#each getRequiredProperties}} {{#if @key.getNameIsValid}} {{#with this}} -{{#if refClass}} +{{#if refInfo.refClass}} {{@key.getName}}: '{{> refclass_with_module }}', {{else}} {{#if name}} @@ -34,7 +34,7 @@ def __new__( {{/unless}} {{#each optionalProperties}} {{#if @key.getNameIsValid}} -{{#if refClass}} +{{#if refInfo.refClass}} {{@key.getName}}: typing.Union['{{> refclass_with_module }}', schemas.Unset] = schemas.unset, {{else}} {{@key.getName}}: typing.Union[Schema_.Properties.{{name.getCamelCaseName}}, {{> model_templates/schema_python_types }}schemas.Unset] = schemas.unset, @@ -44,7 +44,7 @@ def __new__( configuration_: typing.Optional[schemas.configuration_module.Configuration] = None, {{#with additionalProperties}} {{#unless getIsBooleanSchemaFalse}} -{{#if refClass}} +{{#if refInfo.refClass}} **kwargs: '{{> refclass_with_module }}', {{else}} **kwargs: typing.Union[Schema_.{{name.getCamelCaseName}}, {{> model_templates/schema_python_types }}], diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/notes_msg.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/notes_msg.handlebars index 6e910820810..686477c1a3d 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/notes_msg.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/notes_msg.handlebars @@ -1 +1 @@ -{{#unless isArray}}{{#unless refClass}}{{#with allowableValues}} must be one of [{{#each enumVars}}{{#eq value "schemas.NoneClass.NONE"}}None{{else}}{{#eq value "schemas.BoolClass.TRUE"}}True{{else}}{{#eq value "schemas.BoolClass.FALSE"}}False{{else}}{{{value}}}{{/eq}}{{/eq}}{{/eq}}, {{/each}}]{{/with}}{{#if defaultValue}}{{#unless requiredProperties}} if omitted the server will use the default value of {{{defaultValue}}}{{/unless}}{{/if}}{{#eq getFormat "uuid"}} value must be a uuid{{/eq}}{{#eq getFormat "date"}} value must conform to RFC-3339 full-date YYYY-MM-DD{{/eq}}{{#eq getFormat "date-time"}} value must conform to RFC-3339 date-time{{/eq}}{{#eq getFormat "number"}} value must be numeric and storable in decimal.Decimal{{/eq}}{{#eq getFormat "int32"}} value must be a 32 bit integer{{/eq}}{{#eq getFormat "int64"}} value must be a 64 bit integer{{/eq}}{{#eq getFormat "double"}} value must be a 64 bit float{{/eq}}{{#eq getFormat "float"}} value must be a 32 bit float{{/eq}}{{/unless}}{{/unless}} \ No newline at end of file +{{#unless isArray}}{{#unless refInfo.refClass}}{{#with allowableValues}} must be one of [{{#each enumVars}}{{#eq value "schemas.NoneClass.NONE"}}None{{else}}{{#eq value "schemas.BoolClass.TRUE"}}True{{else}}{{#eq value "schemas.BoolClass.FALSE"}}False{{else}}{{{value}}}{{/eq}}{{/eq}}{{/eq}}, {{/each}}]{{/with}}{{#if defaultValue}}{{#unless requiredProperties}} if omitted the server will use the default value of {{{defaultValue}}}{{/unless}}{{/if}}{{#eq getFormat "uuid"}} value must be a uuid{{/eq}}{{#eq getFormat "date"}} value must conform to RFC-3339 full-date YYYY-MM-DD{{/eq}}{{#eq getFormat "date-time"}} value must conform to RFC-3339 date-time{{/eq}}{{#eq getFormat "number"}} value must be numeric and storable in decimal.Decimal{{/eq}}{{#eq getFormat "int32"}} value must be a 32 bit integer{{/eq}}{{#eq getFormat "int64"}} value must be a 64 bit integer{{/eq}}{{#eq getFormat "double"}} value must be a 64 bit float{{/eq}}{{#eq getFormat "float"}} value must be a 32 bit float{{/eq}}{{/unless}}{{/unless}} \ No newline at end of file diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_getitem.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_getitem.handlebars index 9d83c29422c..430c8282d91 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_getitem.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_getitem.handlebars @@ -17,7 +17,7 @@ def {{methodName}}( str {{/with}} ] -){{#not properties}}{{#not getRequiredProperties}}{{#with additionalProperties}}{{#unless getIsBooleanSchemaFalse}} -> {{#if refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getName}}{{/if}}{{/unless}}{{/with}}{{/not}}{{/not}}: +){{#not properties}}{{#not getRequiredProperties}}{{#with additionalProperties}}{{#unless getIsBooleanSchemaFalse}} -> {{#if refInfo.refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getName}}{{/if}}{{/unless}}{{/with}}{{/not}}{{/not}}: {{#eq methodName "__getitem__"}} # dict_instance[name] accessor {{/eq}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_getitems.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_getitems.handlebars index b3981981876..fa337243228 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_getitems.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_getitems.handlebars @@ -3,7 +3,7 @@ {{#with this}} @typing.overload -{{#if refClass}} +{{#if refInfo.refClass}} def __getitem__(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> '{{> refclass_with_module }}': ... {{else}} {{#if name}} @@ -23,7 +23,7 @@ def __getitem__(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> {{#each optionalProperties}} @typing.overload -{{#if refClass}} +{{#if refInfo.refClass}} def __getitem__(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> '{{> refclass_with_module }}': ... {{else}} def __getitem__(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> Schema_.Properties.{{name.getCamelCaseName}}: ... @@ -35,7 +35,7 @@ def __getitem__(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> {{#unless getIsBooleanSchemaFalse}} @typing.overload -def __getitem__(self, name: str) -> {{#if refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}: ... +def __getitem__(self, name: str) -> {{#if refInfo.refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}: ... {{/unless}} {{else}} @@ -48,7 +48,7 @@ def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ... {{#with additionalProperties}} {{#unless getIsBooleanSchemaFalse}} -def __getitem__(self, name: str) -> {{#if refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}: +def __getitem__(self, name: str) -> {{#if refInfo.refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}: # dict_instance[name] accessor return super().__getitem__(name) {{/unless}} @@ -59,7 +59,7 @@ def __getitem__(self, name: str) -> {{#if refClass}}'{{> refclass_with_module }} {{#with this}} @typing.overload -{{#if refClass}} +{{#if refInfo.refClass}} def get_item_(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> '{{> refclass_with_module }}': ... {{else}} {{#if name}} @@ -79,7 +79,7 @@ def get_item_(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> sc {{#each optionalProperties}} @typing.overload -{{#if refClass}} +{{#if refInfo.refClass}} def get_item_(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> typing.Union['{{> refclass_with_module }}', schemas.Unset]: ... {{else}} def get_item_(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> typing.Union[Schema_.Properties.{{name.getCamelCaseName}}, schemas.Unset]: ... @@ -91,7 +91,7 @@ def get_item_(self, name: typing_extensions.Literal["{{{@key.getName}}}"]) -> ty {{#unless getIsBooleanSchemaFalse}} @typing.overload -def get_item_(self, name: str) -> typing.Union[{{#if refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}, schemas.Unset]: ... +def get_item_(self, name: str) -> typing.Union[{{#if refInfo.refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}, schemas.Unset]: ... {{/unless}} {{else}} @@ -104,7 +104,7 @@ def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schem {{#with additionalProperties}} {{#unless getIsBooleanSchemaFalse}} -def get_item_(self, name: str) -> {{#if refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}: +def get_item_(self, name: str) -> {{#if refInfo.refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}: return super().get_item_(name) {{/unless}} {{/with}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_type_hints_required.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_type_hints_required.handlebars index 299d1b2198d..740bc36cc6d 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_type_hints_required.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/property_type_hints_required.handlebars @@ -1,7 +1,7 @@ {{#each getRequiredProperties}} {{#if @key.nameIsValid}} {{#with this}} -{{#if refClass}} +{{#if refInfo.refClass}} {{@key.getName}}: '{{> refclass_with_module }}' {{else}} {{#if name}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/schema_list.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/schema_list.handlebars index 3a62c560514..de6a39b01e4 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/schema_list.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/schema_list.handlebars @@ -27,5 +27,5 @@ class {{name.getCamelCaseName}}( {{> model_templates/new }} - def __getitem__(self, i: int) -> {{#with items}}{{#if refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}{{/with}}: + def __getitem__(self, i: int) -> {{#with items}}{{#if refInfo.refClass}}'{{> refclass_with_module }}'{{else}}Schema_.{{name.getCamelCaseName}}{{/if}}{{/with}}: return super().__getitem__(i) diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/var_equals_cls.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/var_equals_cls.handlebars index 9ec371033af..fa1b8ec32eb 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/var_equals_cls.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/model_templates/var_equals_cls.handlebars @@ -1 +1 @@ -{{name.getCamelCaseName}} = {{#or getIsBooleanSchemaTrue getIsBooleanSchemaFalse}}{{#if getIsBooleanSchemaTrue}}schemas.AnyTypeSchema{{else}}schemas.NotAnyTypeSchema{{/if}}{{else}}{{#if refClass}}{{> refclass_with_module }}{{else}}schemas.{{#if isNullable}}Nullable{{/if}}{{#if getIsNull}}None{{/if}}{{#if isAnyType}}AnyType{{/if}}{{#if isMap}}Dict{{/if}}{{#if isArray}}List{{/if}}{{#if isString}}{{#eq format "date"}}Date{{/eq}}{{#eq format "date-time"}}DateTime{{/eq}}{{#eq format "uuid"}}UUID{{/eq}}{{#eq format "number"}}Decimal{{/eq}}{{#eq format "binary"}}Binary{{/eq}}{{#neq format "date"}}{{#neq format "date-time"}}{{#neq format "uuid"}}{{#neq format "number"}}{{#neq format "binary"}}Str{{/neq}}{{/neq}}{{/neq}}{{/neq}}{{/neq}}{{/if}}{{#if isInteger}}{{#eq format "int32"}}Int32{{/eq}}{{#eq format "int64"}}Int64{{/eq}}{{#neq format "int32"}}{{#neq format "int64"}}Int{{/neq}}{{/neq}}{{/if}}{{#if isNumber}}{{#eq format "float"}}Float32{{/eq}}{{#eq format "double"}}Float64{{/eq}}{{#neq format "float"}}{{#neq format "double"}}Number{{/neq}}{{/neq}}{{/if}}{{#if isBoolean}}Bool{{/if}}Schema{{/if}}{{/or}} +{{name.getCamelCaseName}} = {{#or getIsBooleanSchemaTrue getIsBooleanSchemaFalse}}{{#if getIsBooleanSchemaTrue}}schemas.AnyTypeSchema{{else}}schemas.NotAnyTypeSchema{{/if}}{{else}}{{#if refInfo.refClass}}{{> refclass_with_module }}{{else}}schemas.{{#if isNullable}}Nullable{{/if}}{{#if getIsNull}}None{{/if}}{{#if isAnyType}}AnyType{{/if}}{{#if isMap}}Dict{{/if}}{{#if isArray}}List{{/if}}{{#if isString}}{{#eq format "date"}}Date{{/eq}}{{#eq format "date-time"}}DateTime{{/eq}}{{#eq format "uuid"}}UUID{{/eq}}{{#eq format "number"}}Decimal{{/eq}}{{#eq format "binary"}}Binary{{/eq}}{{#neq format "date"}}{{#neq format "date-time"}}{{#neq format "uuid"}}{{#neq format "number"}}{{#neq format "binary"}}Str{{/neq}}{{/neq}}{{/neq}}{{/neq}}{{/neq}}{{/if}}{{#if isInteger}}{{#eq format "int32"}}Int32{{/eq}}{{#eq format "int64"}}Int64{{/eq}}{{#neq format "int32"}}{{#neq format "int64"}}Int{{/neq}}{{/neq}}{{/if}}{{#if isNumber}}{{#eq format "float"}}Float32{{/eq}}{{#eq format "double"}}Float64{{/eq}}{{#neq format "float"}}{{#neq format "double"}}Number{{/neq}}{{/neq}}{{/if}}{{#if isBoolean}}Bool{{/if}}Schema{{/if}}{{/or}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/parameter.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/parameter.handlebars index 6b500b5ca6b..6e29229ce77 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/parameter.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/parameter.handlebars @@ -11,7 +11,7 @@ from {{packageName}} import api_client, exceptions {{> model_templates/imports }} {{#if schema}} {{#with schema}} - {{#unless getRefModule}} + {{#unless refInfo.getRefModule}} from . import {{name.getSnakeCaseName}} {{/unless}} {{/with}} @@ -20,7 +20,7 @@ from . import {{name.getSnakeCaseName}} {{#each getContent}} {{#with this}} {{#with schema}} - {{#unless getRefModule}} + {{#unless refInfo.getRefModule}} from . import {{name.getSnakeCaseName}} {{/unless}} {{/with}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/parameter_doc.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/parameter_doc.handlebars index 28e2ce8e9e8..4d668d5e4a2 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/parameter_doc.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/parameter_doc.handlebars @@ -2,13 +2,13 @@ ## {{packageName}}.components.parameters.{{parameter.componentModule}} {{/if}} -{{#if parameter.ref}} - {{#if parameter.ref.schema}} - {{#with parameter.ref.schema}} +{{#if parameter.refInfo}} + {{#if parameter.refInfo.getRef.schema}} + {{#with parameter.refInfo.getRef.schema}} {{> api_doc_schema_type_hint schemaNamePrefix1=../name.getSnakeCaseName }} {{/with}} {{else}} - {{#each parameter.ref.getContent}} + {{#each parameter.refInfo.getRef.getContent}} {{#with this}} {{#with schema}} {{> api_doc_schema_type_hint schemaNamePrefix1=../name.getSnakeCaseName }} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/parameter_instance.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/parameter_instance.handlebars index 564f0db5daf..e88df8fa57b 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/parameter_instance.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/parameter_instance.handlebars @@ -27,8 +27,8 @@ class {{name.getCamelCaseName}}(api_client.{{#if noName}}Header{{/if}}{{#if isQu {{/if}} {{#if schema}} {{#with schema}} - {{#if getRefModule}} - schema = {{getRefModule}}.{{getRefClass}} + {{#if refInfo.getRefModule}} + schema = {{refInfo.getRefModule}}.{{refInfo.getRefClass}} {{else}} schema = {{name.getSnakeCaseName}}.{{name.getCamelCaseName}} {{/if}} @@ -37,7 +37,7 @@ class {{name.getCamelCaseName}}(api_client.{{#if noName}}Header{{/if}}{{#if isQu {{#if getContent}} content = { {{#each getContent}} - "{{@key}}": {{#with this}}{{#with schema}}{{#if getRefModule}}{{getRefModule}}.{{getRefClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}{{/with}}{{/with}}, + "{{@key}}": {{#with this}}{{#with schema}}{{#if refInfo.getRefModule}}{{refInfo.getRefModule}}.{{refInfo.getRefClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}{{/with}}{{/with}}, {{/each}} } {{/if}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/refclass_partial.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/refclass_partial.handlebars index cb5f6188d5f..508059747c1 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/refclass_partial.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/refclass_partial.handlebars @@ -1 +1 @@ -[**{{refClass}}**]({{#eq refModule null}}#{{refClass}}{{else}}{{complexTypePrefix}}{{> refclass_with_module }}.md{{/eq}}) \ No newline at end of file +[**{{refInfo.refClass}}**]({{#eq refInfo.refModule null}}#{{refInfo.refClass}}{{else}}{{complexTypePrefix}}{{> refclass_with_module }}.md{{/eq}}) \ No newline at end of file diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/refclass_with_module.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/refclass_with_module.handlebars index 55a6cbd199b..cd9f5d94cbb 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/refclass_with_module.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/refclass_with_module.handlebars @@ -1 +1 @@ -{{#if refModule}}{{refModule}}.{{/if}}{{refClass}} \ No newline at end of file +{{#if refInfo.refModule}}{{refInfo.refModule}}.{{/if}}{{refInfo.refClass}} \ No newline at end of file diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/request_body.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/request_body.handlebars index 0695618736a..826a2b68288 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/request_body.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/request_body.handlebars @@ -8,7 +8,7 @@ from {{packageName}} import api_client, exceptions {{#each content}} {{#with this}} {{#with schema}} - {{#unless getRefModule}} + {{#unless refInfo.getRefModule}} from . import {{name.getSnakeCaseName}} {{/unless}} {{/with}} @@ -21,8 +21,8 @@ class {{name.getCamelCaseName}}(api_client.RequestBody): '{{{@key}}}': api_client.MediaType( {{#with this}} {{#with schema}} - {{#if getRefModule}} - schema={{getRefModule}}.{{getRefClass}}, + {{#if refInfo.getRefModule}} + schema={{refInfo.getRefModule}}.{{refInfo.getRefClass}}, {{else}} schema={{name.getSnakeCaseName}}.{{name.getCamelCaseName}}, {{/if}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/response.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/response.handlebars index 4de5979ab39..955aacb9a4c 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/response.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/response.handlebars @@ -16,15 +16,15 @@ from {{packageName}} import schemas {{#if getContent}} {{#each content}} {{#with this.schema}} - {{#unless refModule}} + {{#unless refInfo.refModule}} from . import {{name.getSnakeCaseName}} {{/unless}} {{/with}} {{/each}} {{/if}} {{#each headers}} -{{#if refModule}} -from {{packageName}}.components.headers import {{refModule}} +{{#if refInfo.refModule}} +from {{packageName}}.components.headers import {{refInfo.refModule}} {{else}} from . import {{name.getSnakeCaseName}} {{/if}} @@ -42,8 +42,8 @@ class ApiResponse(api_client.ApiResponse): {{#each content}} {{#if this.schema}} {{#with this.schema}} - {{#if refModule}} - {{refModule}}.{{refClass}}, + {{#if refInfo.refModule}} + {{refInfo.refModule}}.{{refInfo.refClass}}, {{else}} {{name.getSnakeCaseName}}.{{name.getCamelCaseName}}, {{/if}} @@ -64,8 +64,8 @@ class ApiResponse(api_client.ApiResponse): {{#each content}} {{#if this.schema}} {{#with this.schema}} - {{#if refModule}} - {{refModule}}.{{refClass}}, + {{#if refInfo.refModule}} + {{refInfo.refModule}}.{{refInfo.refClass}}, {{else}} {{name.getSnakeCaseName}}.{{name.getCamelCaseName}}, {{/if}} @@ -96,8 +96,8 @@ class {{name.getCamelCaseName}}(api_client.OpenApiResponse[ApiResponse]): '{{{@key}}}': api_client.MediaType( {{#if this.schema}} {{#with this.schema}} - {{#if refModule}} - {{refModule}}.{{refClass}}, + {{#if refInfo.refModule}} + {{refInfo.refModule}}.{{refInfo.refClass}}, {{else}} {{name.getSnakeCaseName}}.{{name.getCamelCaseName}}, {{/if}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/response_doc.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/response_doc.handlebars index bf120fb1380..fb6673a49b0 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/response_doc.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/response_doc.handlebars @@ -39,17 +39,17 @@ Key | Accessed Type | Description | Notes ------------- | ------------- | ------------- | ------------- {{#each headers}} {{#with this}} - {{#if ref}} - {{#with ref}} + {{#if refInfo}} + {{#with refInfo.getRef}} {{#if schema}} {{#with schema}} -{{../@key}} | [{{../../refModule}}.schema]({{#unless ../../../componentModule}}../{{/unless}}../../components/headers/{{../../refModule}}.md#schema) | | {{#unless required}}optional{{/unless}} +{{../@key}} | [{{../../refInfo.refModule}}.schema]({{#unless ../../../componentModule}}../{{/unless}}../../components/headers/{{../../refInfo.refModule}}.md#schema) | | {{#unless required}}optional{{/unless}} {{/with}} {{else}} {{#each getContent}} {{#with this}} {{#with schema}} -{{../../@key}} | [{{../../../refModule}}.{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}]({{#unless ../../../../componentModule}}../{{/unless}}../../components/headers/{{../../../refModule}}.md#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}) | | {{#unless required}}optional{{/unless}} +{{../../@key}} | [{{../../../refInfo.refModule}}.{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}]({{#unless ../../../../componentModule}}../{{/unless}}../../components/headers/{{../../../refInfo.refModule}}.md#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}) | | {{#unless required}}optional{{/unless}} {{/with}} {{/with}} {{/each}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/response_header_optional_oneline.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/response_header_optional_oneline.handlebars index 4ca3dfcc955..f3ad9b7be08 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/response_header_optional_oneline.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/response_header_optional_oneline.handlebars @@ -1,13 +1,13 @@ -{{#if ref}} - {{#with ref}} +{{#if refInfo}} + {{#with refInfo.getRef}} {{#unless required}} {{#if schema}} {{#with schema}} - '{{../@key}}': typing.Union[{{../../refModule}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}], + '{{../@key}}': typing.Union[{{../../refInfo.refModule}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}], {{/with}} {{else}} {{#each getContent}} - '{{../@key}}': {{#with this}}{{#with schema}}typing.Union[{{../../../refModule}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}} + '{{../@key}}': {{#with this}}{{#with schema}}typing.Union[{{../../../refInfo.refModule}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}} {{/each}} {{/if}} {{/unless}} @@ -16,11 +16,11 @@ {{#unless required}} {{#if schema}} {{#with schema}} - '{{../@key}}': typing.Union[{{../name.getSnakeCaseName}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}], + '{{../@key}}': typing.Union[{{../name.getSnakeCaseName}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}], {{/with}} {{else}} {{#each getContent}} - '{{../@key}}': {{#with this}}{{#with schema}}typing.Union[{{../name.getSnakeCaseName}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}} + '{{../@key}}': {{#with this}}{{#with schema}}typing.Union[{{../name.getSnakeCaseName}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}} {{/each}} {{/if}} {{/unless}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/response_header_required_oneline.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/response_header_required_oneline.handlebars index bcc4c651452..76294ad9b38 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/response_header_required_oneline.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/response_header_required_oneline.handlebars @@ -1,13 +1,13 @@ -{{#if ref}} - {{#with ref}} +{{#if refInfo}} + {{#with refInfo.getRef}} {{#if required}} {{#if schema}} {{#with schema}} - '{{../@key}}': typing.Union[{{../../refModule}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}], + '{{../@key}}': typing.Union[{{../../refInfo.refModule}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}], {{/with}} {{else}} {{#each getContent}} - '{{../@key}}': {{#with this}}{{#with schema}}typing.Union[{{../../../refModule}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}} + '{{../@key}}': {{#with this}}{{#with schema}}typing.Union[{{../../../refInfo.refModule}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}} {{/each}} {{/if}} {{/if}} @@ -16,11 +16,11 @@ {{#if required}} {{#if schema}} {{#with schema}} - '{{../@key}}': typing.Union[{{../name.getSnakeCaseName}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}], + '{{../@key}}': typing.Union[{{../name.getSnakeCaseName}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}], {{/with}} {{else}} {{#each getContent}} - '{{../@key}}': {{#with this}}{{#with schema}}typing.Union[{{../name.getSnakeCaseName}}.{{#if refModule}}{{refModule}}.{{refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}} + '{{../@key}}': {{#with this}}{{#with schema}}typing.Union[{{../name.getSnakeCaseName}}.{{#if refInfo.refModule}}{{refInfo.refModule}}.{{refInfo.refClass}}{{else}}{{name.getSnakeCaseName}}.{{name.getCamelCaseName}}{{/if}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}} {{/each}} {{/if}} {{/if}} diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/response_header_schema_and_def.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/response_header_schema_and_def.handlebars index 179bb3b7d5e..c89c2a24ec7 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/response_header_schema_and_def.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/response_header_schema_and_def.handlebars @@ -26,6 +26,6 @@ class {{xParamsName}}: parameters = [ {{#each xParams}} - {{#if refModule}}{{refModule}}{{else}}{{name.getSnakeCaseName}}{{/if}}.{{#if refClass}}{{refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}, + {{#if refInfo.refModule}}{{refInfo.refModule}}{{else}}{{name.getSnakeCaseName}}{{/if}}.{{#if refInfo.refClass}}{{refInfo.refClass}}{{else}}{{name.getCamelCaseName}}{{/if}}, {{/each}} ] \ No newline at end of file diff --git a/modules/openapi-json-schema-generator/src/main/resources/python/schema_doc.handlebars b/modules/openapi-json-schema-generator/src/main/resources/python/schema_doc.handlebars index 6f30c3312aa..6b324e13bcb 100644 --- a/modules/openapi-json-schema-generator/src/main/resources/python/schema_doc.handlebars +++ b/modules/openapi-json-schema-generator/src/main/resources/python/schema_doc.handlebars @@ -13,17 +13,17 @@ Input Type | Accessed Type | Description | Notes Key | Input Type | Accessed Type | Description | Notes ------------ | ------------- | ------------- | ------------- | ------------- {{#each getRequiredProperties}} -**{{@key.getName}}** | {{#if refClass}}{{> refclass_partial }}{{else}}{{#if isComplicated}}[{{/if}}{{> model_templates/schema_python_types }}{{#if isComplicated}}](#{{@key.getName}}){{/if}}{{/if}} | {{#if refClass}}{{> refclass_partial }}{{else}}{{#if isComplicated}}[{{/if}}{{> model_templates/schema_accessed_types }}{{#if isComplicated}}](#{{@key.getName}}){{/if}}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} +**{{@key.getName}}** | {{#if refInfo.refClass}}{{> refclass_partial }}{{else}}{{#if isComplicated}}[{{/if}}{{> model_templates/schema_python_types }}{{#if isComplicated}}](#{{@key.getName}}){{/if}}{{/if}} | {{#if refInfo.refClass}}{{> refclass_partial }}{{else}}{{#if isComplicated}}[{{/if}}{{> model_templates/schema_accessed_types }}{{#if isComplicated}}](#{{@key.getName}}){{/if}}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} {{/each}} {{#each optionalProperties}} -**{{@key.getName}}** | {{#if refClass}}{{> refclass_partial }}{{else}}{{#if isComplicated}}[{{/if}}{{> model_templates/schema_python_types }}{{#if isComplicated}}](#{{@key.getName}}){{/if}}{{/if}} | {{#if refClass}}{{> refclass_partial }}{{else}}{{#if isComplicated}}[{{/if}}{{> model_templates/schema_accessed_types }}{{#if isComplicated}}](#{{@key.getName}}){{/if}}{{/if}} | {{#if description}}{{description}}{{/if}} | [optional]{{> model_templates/notes_msg }} +**{{@key.getName}}** | {{#if refInfo.refClass}}{{> refclass_partial }}{{else}}{{#if isComplicated}}[{{/if}}{{> model_templates/schema_python_types }}{{#if isComplicated}}](#{{@key.getName}}){{/if}}{{/if}} | {{#if refInfo.refClass}}{{> refclass_partial }}{{else}}{{#if isComplicated}}[{{/if}}{{> model_templates/schema_accessed_types }}{{#if isComplicated}}](#{{@key.getName}}){{/if}}{{/if}} | {{#if description}}{{description}}{{/if}} | [optional]{{> model_templates/notes_msg }} {{/each}} {{#with additionalProperties}} {{#unless getIsBooleanSchemaFalse}} {{#if getIsBooleanSchemaTrue}} **any_string_name** | {{> model_templates/schema_python_types }} | {{> model_templates/schema_accessed_types }} | any string name can be used but the value must be the correct type{{#if description}} {{description}}{{/if}} | [optional] {{else}} -**any_string_name** | {{#unless refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#unless refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | any string name can be used but the value must be the correct type{{#if description}} {{description}}{{/if}} | [optional]{{> model_templates/notes_msg }} +**any_string_name** | {{#unless refInfo.refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | any string name can be used but the value must be the correct type{{#if description}} {{description}}{{/if}} | [optional]{{> model_templates/notes_msg }} {{/if}} {{/unless}} {{else}} @@ -32,7 +32,7 @@ Key | Input Type | Accessed Type | Description | Notes {{/or}} {{#each requiredProperties}} {{#if this}} -{{#unless refClass}} +{{#unless refInfo.refClass}} {{#if isComplicated}} # {{@key.getName}} @@ -42,7 +42,7 @@ Key | Input Type | Accessed Type | Description | Notes {{/if}} {{/each}} {{#each optionalProperties}} -{{#unless refClass}} +{{#unless refInfo.refClass}} {{#if isComplicated}} # {{@key.getName}} @@ -53,7 +53,7 @@ Key | Input Type | Accessed Type | Description | Notes {{#with additionalProperties}} {{#unless getIsBooleanSchemaFalse}} {{#unless getIsBooleanSchemaTrue}} -{{#unless refClass}} +{{#unless refInfo.refClass}} {{#if isComplicated}} # any_string_name @@ -69,8 +69,8 @@ Key | Input Type | Accessed Type | Description | Notes Class Name | Input Type | Accessed Type | Description | Notes ------------- | ------------- | ------------- | ------------- | ------------- {{#with items}} -{{#unless refClass}}{{#or isArray isMap allOf anyOf oneOf not}}[{{/or}}{{name.getName}}{{#or isArray isMap allOf anyOf oneOf not}}](#{{name.getName}}){{/or}}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#unless refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#unless refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} -{{#unless refClass}} +{{#unless refInfo.refClass}}{{#or isArray isMap allOf anyOf oneOf not}}[{{/or}}{{name.getName}}{{#or isArray isMap allOf anyOf oneOf not}}](#{{name.getName}}){{/or}}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} +{{#unless refInfo.refClass}} {{#if isComplicated}} # {{name.getName}} @@ -87,10 +87,10 @@ Class Name | Input Type | Accessed Type | Description | Notes Class Name | Input Type | Accessed Type | Description | Notes ------------- | ------------- | ------------- | ------------- | ------------- {{#each allOf}} -{{#if refClass}}{{> refclass_partial }}{{else}}[{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/if}} | {{#unless refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#unless refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} +{{#if refInfo.refClass}}{{> refclass_partial }}{{else}}[{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} {{/each}} {{#each allOf}} -{{#unless refClass}} +{{#unless refInfo.refClass}} # {{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}} {{> schema_doc }} @@ -102,10 +102,10 @@ Class Name | Input Type | Accessed Type | Description | Notes Class Name | Input Type | Accessed Type | Description | Notes ------------- | ------------- | ------------- | ------------- | ------------- {{#each anyOf}} -{{#if refClass}}{{> refclass_partial }}{{else}}[{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/if}} | {{#unless refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#unless refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} +{{#if refInfo.refClass}}{{> refclass_partial }}{{else}}[{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} {{/each}} {{#each anyOf}} -{{#unless refClass}} +{{#unless refInfo.refClass}} # {{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}} {{> schema_doc }} @@ -117,10 +117,10 @@ Class Name | Input Type | Accessed Type | Description | Notes Class Name | Input Type | Accessed Type | Description | Notes ------------- | ------------- | ------------- | ------------- | ------------- {{#each oneOf}} -{{#if refClass}}{{> refclass_partial }}{{else}}[{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/if}} | {{#unless refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#unless refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} +{{#if refInfo.refClass}}{{> refclass_partial }}{{else}}[{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} {{/each}} {{#each oneOf}} -{{#unless refClass}} +{{#unless refInfo.refClass}} # {{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}} {{> schema_doc }} @@ -132,8 +132,8 @@ Class Name | Input Type | Accessed Type | Description | Notes Class Name | Input Type | Accessed Type | Description | Notes ------------- | ------------- | ------------- | ------------- | ------------- {{#with not}} -{{#if refClass}}{{> refclass_partial }}{{else}}[{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/if}} | {{#unless refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#unless refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} -{{#unless refClass}} +{{#if refInfo.refClass}}{{> refclass_partial }}{{else}}[{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}](#{{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}}){{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_python_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#unless refInfo.refClass}}{{> model_templates/schema_accessed_types }}{{/unless}}{{#if refInfo.refClass}}{{> refclass_partial }}{{/if}} | {{#if description}}{{description}}{{/if}} |{{> model_templates/notes_msg }} +{{#unless refInfo.refClass}} # {{#if name.getNameIsValid}}{{name.getName}}{{else}}{{name.getSnakeCaseName}}{{/if}} {{> schema_doc }} diff --git a/modules/openapi-json-schema-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java b/modules/openapi-json-schema-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java index 945fc5cd17f..0b5dccbaeed 100644 --- a/modules/openapi-json-schema-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java +++ b/modules/openapi-json-schema-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java @@ -259,7 +259,7 @@ public void testDateTimeFormParameterHasDefaultValue() { RequestBody reqBody = openAPI.getPaths().get("/thingy/{date}").getPost().getRequestBody(); CodegenRequestBody codegenParameter = codegen.fromRequestBody(reqBody, "#/paths/~1thingy~1{date}/post/requestBody"); - Assert.assertNotNull(codegenParameter.getContent().get("application/x-www-form-urlencoded").getSchema().getRef()); + Assert.assertNotNull(codegenParameter.getContent().get("application/x-www-form-urlencoded").getSchema().getRefInfo()); Schema specModel = openAPI.getComponents().getSchemas().get("updatePetWithForm_request"); CodegenSchema model = codegen.fromSchema( @@ -459,8 +459,8 @@ public void testComposedSchemaOneOfWithProperties() { "#/components/schemas/fruit" ); - Assert.assertEquals(fruit.getOneOf().get(0).refClass, "Apple"); - Assert.assertEquals(fruit.getOneOf().get(1).refClass, "Banana"); + Assert.assertEquals(fruit.getOneOf().get(0).getRefInfo().getRefClass(), "Apple"); + Assert.assertEquals(fruit.getOneOf().get(1).getRefInfo().getRefClass(), "Banana"); Assert.assertEquals(fruit.getOptionalProperties().size(), 1); } @@ -1522,11 +1522,11 @@ public void testCallbacks() { switch (req.httpMethod.toLowerCase(Locale.getDefault())) { case "post": Assert.assertEquals(req.operationId, "onDataDataPost"); - Assert.assertEquals(req.requestBody.getContent().get("application/json").getSchema().refClass, "NewNotificationData"); + Assert.assertEquals(req.requestBody.getContent().get("application/json").getSchema().getRefInfo().getRefClass(), "NewNotificationData"); break; case "delete": Assert.assertEquals(req.operationId, "onDataDataDelete"); - Assert.assertEquals(req.requestBody.getContent().get("application/json").getSchema().refClass, "DeleteNotificationData"); + Assert.assertEquals(req.requestBody.getContent().get("application/json").getSchema().getRefInfo().getRefClass(), "DeleteNotificationData"); break; default: Assert.fail(String.format(Locale.getDefault(), "invalid callback request http method '%s'", req.httpMethod)); @@ -1604,7 +1604,7 @@ public void testNullableProperty() { "#/components/schemas/User", "#/components/schemas/User/properties/address" ); - Assert.assertTrue(property.getRef().isNullable); + Assert.assertTrue(property.getRefInfo().getRef().isNullable); } @Test @@ -1678,7 +1678,7 @@ public void testDeprecatedRef() { requestProperties.get("deprecated"), "#/components/schemas/complex", "#/components/schemas/complex/properties/deprecated" - ).getRef().deprecated); + ).getRefInfo().getRef().deprecated); Assert.assertFalse(codegen.fromSchema( requestProperties.get("current"), "#/components/schemas/complex", @@ -1894,7 +1894,7 @@ public void testAlias() { "#/components/schemas/MyParameterTextField", "#/components/schemas/MyParameterTextField" ); - Assert.assertEquals(typeAliasModel.getRef().isString, true); + Assert.assertEquals(typeAliasModel.getRefInfo().getRef().isString, true); } private void verifyPersonDiscriminator(CodegenDiscriminator discriminator) { @@ -2017,7 +2017,7 @@ public void importMapping() { Assert.assertEquals(codegenModel.getProperties().size(), 1); CodegenKey ck = codegen.getKey("typeAlias"); - Assert.assertEquals(codegenModel.getOptionalProperties().get(ck).getRef().isString, true); + Assert.assertEquals(codegenModel.getOptionalProperties().get(ck).getRefInfo().getRef().isString, true); } @Test @@ -2037,7 +2037,7 @@ public void schemaMapping() { Assert.assertEquals(codegenModel.getProperties().size(), 1); - Assert.assertEquals(codegenModel.getProperties().get(codegen.getKey("typeAlias")).refClass, "TypeAlias"); + Assert.assertEquals(codegenModel.getProperties().get(codegen.getKey("typeAlias")).getRefInfo().getRefClass(), "TypeAlias"); } @Test @@ -2088,8 +2088,8 @@ public void arrayInnerReferencedSchemaMarkedAsModel_30() { CodegenRequestBody codegenParameter = codegen.fromRequestBody(body, "#/paths/~1examples/post/requestBody"); Assert.assertTrue(codegenParameter.getContent().get("application/json").getSchema().isArray); - Assert.assertTrue(codegenParameter.getContent().get("application/json").getSchema().items.refClass != null); - Assert.assertTrue(codegenParameter.getContent().get("application/json").getSchema().items.getRef() != null); + Assert.assertTrue(codegenParameter.getContent().get("application/json").getSchema().items.getRefInfo().getRefClass() != null); + Assert.assertTrue(codegenParameter.getContent().get("application/json").getSchema().items.getRefInfo() != null); } @Test @@ -2214,7 +2214,7 @@ public void inlineAllOfSchemaDoesNotThrowException() { "#/components/schemas/" + modelName, "#/components/schemas/" + modelName ); - assertEquals(cm.getAllOf().get(0).refClass, "UserTimeBase"); + assertEquals(cm.getAllOf().get(0).getRefInfo().getRefClass(), "UserTimeBase"); assertEquals(openAPI.getComponents().getSchemas().size(), 2); assertNull(cm.getDiscriminator()); } @@ -2391,19 +2391,19 @@ public void testAdditionalPropertiesPresentInModelProperties() { CodegenKey ck = codegen.getKey("map_with_additional_properties_unset"); mapWithAddPropsUnset = cm.getProperties().get(ck); assertEquals(mapWithAddPropsUnset.getAdditionalProperties(), null); - assertEquals(mapWithAddPropsUnset.getRefClass(), "AdditionalPropertiesUnset"); + assertEquals(mapWithAddPropsUnset.getRefInfo().getRefClass(), "AdditionalPropertiesUnset"); mapWithAddPropsTrue = cm.getProperties().get(codegen.getKey("map_with_additional_properties_true")); assertEquals(mapWithAddPropsTrue.getAdditionalProperties(), null); - assertEquals(mapWithAddPropsTrue.getRefClass(), "AdditionalPropertiesTrue"); + assertEquals(mapWithAddPropsTrue.getRefInfo().getRefClass(), "AdditionalPropertiesTrue"); mapWithAddPropsFalse = cm.getProperties().get(codegen.getKey("map_with_additional_properties_false")); assertEquals(mapWithAddPropsFalse.getAdditionalProperties(), null); - assertEquals(mapWithAddPropsFalse.getRefClass(), "AdditionalPropertiesFalse"); + assertEquals(mapWithAddPropsFalse.getRefInfo().getRefClass(), "AdditionalPropertiesFalse"); mapWithAddPropsSchema = cm.getProperties().get(codegen.getKey("map_with_additional_properties_schema")); assertEquals(mapWithAddPropsSchema.getAdditionalProperties(), null); - assertEquals(mapWithAddPropsSchema.getRefClass(), "AdditionalPropertiesSchema"); + assertEquals(mapWithAddPropsSchema.getRefInfo().getRefClass(), "AdditionalPropertiesSchema"); modelName = "ObjectModelWithAddPropsInProps"; sc = openAPI.getComponents().getSchemas().get(modelName); @@ -2468,15 +2468,15 @@ public void testAdditionalPropertiesPresentInParameters() { operation = openAPI.getPaths().get(path).getPost(); co = codegen.fromOperation(path, "POST", operation, null); mapWithAddPropsUnset = co.queryParams.get(0); - assertEquals(mapWithAddPropsUnset.getSchema().getRef().getAdditionalProperties(), null); + assertEquals(mapWithAddPropsUnset.getSchema().getRefInfo().getRef().getAdditionalProperties(), null); mapWithAddPropsTrue = co.queryParams.get(1); - assertNotNull(mapWithAddPropsTrue.getSchema().getRef()); - assertTrue(mapWithAddPropsTrue.getSchema().getRef().getAdditionalProperties().getIsBooleanSchemaTrue()); + assertNotNull(mapWithAddPropsTrue.getSchema().getRefInfo()); + assertTrue(mapWithAddPropsTrue.getSchema().getRefInfo().getRef().getAdditionalProperties().getIsBooleanSchemaTrue()); mapWithAddPropsFalse = co.queryParams.get(2); - assertNotNull(mapWithAddPropsFalse.getSchema().getRef().getAdditionalProperties()); - assertTrue(mapWithAddPropsFalse.getSchema().getRef().getAdditionalProperties().getIsBooleanSchemaFalse()); + assertNotNull(mapWithAddPropsFalse.getSchema().getRefInfo().getRef().getAdditionalProperties()); + assertTrue(mapWithAddPropsFalse.getSchema().getRefInfo().getRef().getAdditionalProperties().getIsBooleanSchemaFalse()); mapWithAddPropsSchema = co.queryParams.get(3); - assertNotNull(mapWithAddPropsSchema.getSchema().getRef()); + assertNotNull(mapWithAddPropsSchema.getSchema().getRefInfo()); path = "/additional_properties/"; operation = openAPI.getPaths().get(path).getPost(); @@ -2532,15 +2532,15 @@ public void testAdditionalPropertiesPresentInResponses() { operation = openAPI.getPaths().get(path).getPost(); co = codegen.fromOperation(path, "POST", operation, null); mapWithAddPropsUnset = co.responses.get("200"); - assertEquals(mapWithAddPropsUnset.getContent().get("application/json").getSchema().getRef().getAdditionalProperties(), null); + assertEquals(mapWithAddPropsUnset.getContent().get("application/json").getSchema().getRefInfo().getRef().getAdditionalProperties(), null); mapWithAddPropsTrue = co.responses.get("201"); - assertNotNull(mapWithAddPropsTrue.getContent().get("application/xml").getSchema().getRef().getAdditionalProperties()); - assertTrue(mapWithAddPropsTrue.getContent().get("application/xml").getSchema().getRef().getAdditionalProperties().getIsBooleanSchemaTrue()); + assertNotNull(mapWithAddPropsTrue.getContent().get("application/xml").getSchema().getRefInfo().getRef().getAdditionalProperties()); + assertTrue(mapWithAddPropsTrue.getContent().get("application/xml").getSchema().getRefInfo().getRef().getAdditionalProperties().getIsBooleanSchemaTrue()); mapWithAddPropsFalse = co.responses.get("202"); - assertNotNull(mapWithAddPropsFalse.getContent().get("application/x-www-form-urlencoded").getSchema().getRef().getAdditionalProperties()); - assertTrue(mapWithAddPropsFalse.getContent().get("application/x-www-form-urlencoded").getSchema().getRef().getAdditionalProperties().getIsBooleanSchemaFalse()); + assertNotNull(mapWithAddPropsFalse.getContent().get("application/x-www-form-urlencoded").getSchema().getRefInfo().getRef().getAdditionalProperties()); + assertTrue(mapWithAddPropsFalse.getContent().get("application/x-www-form-urlencoded").getSchema().getRefInfo().getRef().getAdditionalProperties().getIsBooleanSchemaFalse()); mapWithAddPropsSchema = co.responses.get("203"); - assertNotNull(mapWithAddPropsSchema.getContent().get("application/*").getSchema().getRef()); + assertNotNull(mapWithAddPropsSchema.getContent().get("application/*").getSchema().getRefInfo()); path = "/additional_properties/"; operation = openAPI.getPaths().get(path).getPost(); @@ -2658,12 +2658,12 @@ public void testIsXPresence() { path = "/ref_date_with_validation/{date}"; operation = openAPI.getPaths().get(path).getPost(); co = codegen.fromOperation(path, "POST", operation, null); - assertFalse(co.pathParams.get(0).getSchema().getRef().isString); - assertTrue(co.pathParams.get(0).getSchema().getRef().isDate); - assertFalse(co.requestBody.getContent().get("application/json").getSchema().getRef().isString); - assertTrue(co.requestBody.getContent().get("application/json").getSchema().getRef().isDate); - assertFalse(co.responses.get("200").getContent().get("application/json").getSchema().getRef().isString); - assertTrue(co.responses.get("200").getContent().get("application/json").getSchema().getRef().isDate); + assertFalse(co.pathParams.get(0).getSchema().getRefInfo().getRef().isString); + assertTrue(co.pathParams.get(0).getSchema().getRefInfo().getRef().isDate); + assertFalse(co.requestBody.getContent().get("application/json").getSchema().getRefInfo().getRef().isString); + assertTrue(co.requestBody.getContent().get("application/json").getSchema().getRefInfo().getRef().isDate); + assertFalse(co.responses.get("200").getContent().get("application/json").getSchema().getRefInfo().getRef().isString); + assertTrue(co.responses.get("200").getContent().get("application/json").getSchema().getRefInfo().getRef().isDate); path = "/date_with_validation/{date}"; operation = openAPI.getPaths().get(path).getPost(); @@ -2699,12 +2699,12 @@ public void testIsXPresence() { path = "/ref_date_time_with_validation/{dateTime}"; operation = openAPI.getPaths().get(path).getPost(); co = codegen.fromOperation(path, "POST", operation, null); - assertFalse(co.pathParams.get(0).getSchema().getRef().isString); - assertTrue(co.pathParams.get(0).getSchema().getRef().isDateTime); - assertFalse(co.requestBody.getContent().get("application/json").getSchema().getRef().isString); - assertTrue(co.requestBody.getContent().get("application/json").getSchema().getRef().isDateTime); - assertFalse(co.responses.get("200").getContent().get("application/json").getSchema().getRef().isString); - assertTrue(co.responses.get("200").getContent().get("application/json").getSchema().getRef().isDateTime); + assertFalse(co.pathParams.get(0).getSchema().getRefInfo().getRef().isString); + assertTrue(co.pathParams.get(0).getSchema().getRefInfo().getRef().isDateTime); + assertFalse(co.requestBody.getContent().get("application/json").getSchema().getRefInfo().getRef().isString); + assertTrue(co.requestBody.getContent().get("application/json").getSchema().getRefInfo().getRef().isDateTime); + assertFalse(co.responses.get("200").getContent().get("application/json").getSchema().getRefInfo().getRef().isString); + assertTrue(co.responses.get("200").getContent().get("application/json").getSchema().getRefInfo().getRef().isDateTime); path = "/date_time_with_validation/{dateTime}"; operation = openAPI.getPaths().get(path).getPost(); @@ -2726,9 +2726,9 @@ public void testIsXPresence() { path = "/ref_null/{param}"; operation = openAPI.getPaths().get(path).getPost(); co = codegen.fromOperation(path, "POST", operation, null); - assertTrue(co.pathParams.get(0).getSchema().getRef().isNull); - assertTrue(co.requestBody.getContent().get("application/json").getSchema().getRef().isNull); - assertTrue(co.responses.get("200").getContent().get("application/json").getSchema().getRef().isNull); + assertTrue(co.pathParams.get(0).getSchema().getRefInfo().getRef().isNull); + assertTrue(co.requestBody.getContent().get("application/json").getSchema().getRefInfo().getRef().isNull); + assertTrue(co.responses.get("200").getContent().get("application/json").getSchema().getRefInfo().getRef().isNull); } @Test @@ -2994,7 +2994,7 @@ public void testVarsAndRequiredVarsPresent() { assertEquals(co.requestBody.getContent().get("application/json").getSchema().getRequiredProperties(), null); // CodegenOperation puts the inline schema into schemas and refs it - assertEquals(co.responses.get("200").getContent().get("application/json").getSchema().refClass, "ObjectWithOptionalAndRequiredPropsRequest"); + assertEquals(co.responses.get("200").getContent().get("application/json").getSchema().getRefInfo().getRefClass(), "ObjectWithOptionalAndRequiredPropsRequest"); modelName = "objectWithOptionalAndRequiredProps_request"; sc = openAPI.getComponents().getSchemas().get(modelName); cm = codegen.fromSchema( @@ -3015,7 +3015,7 @@ public void testVarsAndRequiredVarsPresent() { ); CodegenKey ck = codegen.getKey("a"); CodegenSchema cp = cm.getProperties().get(ck); - assertEquals(cp.refClass, "ObjectWithOptionalAndRequiredPropsRequest"); + assertEquals(cp.getRefInfo().getRefClass(), "ObjectWithOptionalAndRequiredPropsRequest"); } @Test @@ -3876,9 +3876,9 @@ public void testResponses() { co = codegen.fromOperation(path, "GET", operation, null); //assertTrue(co.hasErrorResponseObject); cr = co.responses.get("200"); - assertTrue(cr.getContent().get("application/json").getSchema().getRefClass() != null); + assertTrue(cr.getContent().get("application/json").getSchema().getRefInfo().getRefClass() != null); cr = co.responses.get("500"); - assertTrue(cr.getContent().get("application/application").getSchema().getRefClass() != null); + assertTrue(cr.getContent().get("application/application").getSchema().getRefInfo().getRefClass() != null); path = "/pet"; operation = openAPI.getPaths().get(path).getPut(); @@ -3886,17 +3886,17 @@ public void testResponses() { assertTrue(co.hasErrorResponseObject); cr = co.responses.get("200"); - assertTrue(cr.getContent().get("application/json").getSchema().getRefClass() != null); + assertTrue(cr.getContent().get("application/json").getSchema().getRefInfo().getRefClass() != null); cr = co.responses.get("400"); - assertTrue(cr.getContent().get("application/json").getSchema().getRefClass() != null); + assertTrue(cr.getContent().get("application/json").getSchema().getRefInfo().getRefClass() != null); path = "/pet/findByTags"; operation = openAPI.getPaths().get(path).getGet(); co = codegen.fromOperation(path, "GET", operation, null); assertFalse(co.hasErrorResponseObject); cr = co.responses.get("200"); - assertNotNull(cr.getContent().get("application/json").getSchema().getItems().getRefClass()); + assertNotNull(cr.getContent().get("application/json").getSchema().getItems().getRefInfo().getRefClass()); } @Test @@ -3917,7 +3917,7 @@ public void testRequestParameterContent() { assertNull(mt.getEncoding()); CodegenSchema cp = mt.getSchema(); assertTrue(cp.isMap); - assertEquals(cp.refClass, null); + assertEquals(cp.getRefInfo(), null); assertEquals(cp.name.getName(), "application/json"); CodegenParameter coordinatesReferencedSchema = co.queryParams.get(1); @@ -3926,7 +3926,7 @@ public void testRequestParameterContent() { assertNull(mt.getEncoding()); cp = mt.getSchema(); assertFalse(cp.isMap); // because it is a referenced schema - assertEquals(cp.refClass, "Coordinates"); + assertEquals(cp.getRefInfo().getRefClass(), "Coordinates"); assertEquals(cp.name.getName(), "application/json"); } @@ -3968,7 +3968,7 @@ public void testRequestBodyContent() { assertNull(mt.getEncoding()); cp = mt.getSchema(); assertEquals(cp.name.getName(), "application/json"); - assertEquals(cp.refClass, "Coordinates"); + assertEquals(cp.getRefInfo().getRefClass(), "Coordinates"); codegen.fromSchema( openAPI.getComponents().getSchemas().get("stringWithMinLength"), @@ -3980,7 +3980,7 @@ public void testRequestBodyContent() { assertNull(mt.getEncoding()); cp = mt.getSchema(); assertEquals(cp.name.getName(), "text/plain"); - assertTrue(cp.getRef().isString); + assertTrue(cp.getRefInfo().getRef().isString); codegen.fromSchema( openAPI.getComponents().getSchemas().get("_requestBodyWithEncodingTypes_post_request"), @@ -3991,7 +3991,7 @@ public void testRequestBodyContent() { path = "/requestBodyWithEncodingTypes"; co = codegen.fromOperation(path, "POST", openAPI.getPaths().get(path).getPost(), null); CodegenSchema formSchema = co.requestBody.getContent().get("application/x-www-form-urlencoded").getSchema(); - assertEquals(formSchema.getRef().getProperties().size(), 6); + assertEquals(formSchema.getRefInfo().getRef().getProperties().size(), 6); LinkedHashMap encoding = co.requestBody.getContent().get("application/x-www-form-urlencoded").getEncoding(); assertEquals(encoding.get("int-param").getExplode(), true); @@ -4030,8 +4030,8 @@ public void testResponseContentAndHeader() { ); CodegenHeader header2 = responseHeaders.get("X-Rate-Limit-Ref"); - assertTrue(header2.getRef().getSchema().isUnboundedInteger); - assertEquals(header2.getRef().getSchema().name.getName(), "schema"); + assertTrue(header2.getRefInfo().getRef().getSchema().isUnboundedInteger); + assertEquals(header2.getRefInfo().getRef().getSchema().name.getName(), "schema"); content = cr.getContent(); assertEquals(content.keySet(), new HashSet<>(Arrays.asList("application/json", "text/plain"))); @@ -4039,7 +4039,7 @@ public void testResponseContentAndHeader() { assertNull(mt.getEncoding()); CodegenSchema cp = mt.getSchema(); assertFalse(cp.isMap); // because it is a referenced schema - assertEquals(cp.refClass, "Coordinates"); + assertEquals(cp.getRefInfo().getRefClass(), "Coordinates"); assertEquals(cp.name.getName(), "application/json"); codegen.fromSchema( @@ -4052,7 +4052,7 @@ public void testResponseContentAndHeader() { assertNull(mt.getEncoding()); cp = mt.getSchema(); assertEquals(cp.name.getName(), "text/plain"); - assertTrue(cp.getRef().isString); + assertTrue(cp.getRefInfo().getRef().isString); codegen.fromSchema( openAPI.getComponents().getSchemas().get("coordinates"), @@ -4066,15 +4066,15 @@ public void testResponseContentAndHeader() { mt = content.get("application/json"); assertNull(mt.getEncoding()); cp = mt.getSchema(); - assertTrue(cp.getRef().isMap); - assertEquals(cp.refClass, "Coordinates"); + assertTrue(cp.getRefInfo().getRef().isMap); + assertEquals(cp.getRefInfo().getRefClass(), "Coordinates"); assertEquals(cp.name.getName(), "application/json"); mt = content.get("text/plain"); assertNull(mt.getEncoding()); cp = mt.getSchema(); assertEquals(cp.name.getName(), "text/plain"); - assertTrue(cp.getRef().isString); + assertTrue(cp.getRefInfo().getRef().isString); } @Test @@ -4097,7 +4097,7 @@ public void testUnalias() { RequestBody reqBody = openAPI.getPaths().get("/thingy/{date}").getPost().getRequestBody(); CodegenRequestBody codegenParameter = codegen.fromRequestBody(reqBody, "#/paths/~1thingy~1{date}/post/requestBody"); - Assert.assertNotNull(codegenParameter.getContent().get("application/x-www-form-urlencoded").getSchema().getRef()); + Assert.assertNotNull(codegenParameter.getContent().get("application/x-www-form-urlencoded").getSchema().getRefInfo()); } @Test diff --git a/modules/openapi-json-schema-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java b/modules/openapi-json-schema-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java index add50a2a0c4..e15254ebb01 100644 --- a/modules/openapi-json-schema-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java +++ b/modules/openapi-json-schema-generator/src/test/java/org/openapitools/codegen/DefaultGeneratorTest.java @@ -438,13 +438,13 @@ public void testRefModelValidationProperties() { CodegenRequestBody codegenParameter = config.fromRequestBody( body, "#/paths/~1fake~1StringRegex/post/requestBody"); - Assert.assertEquals(codegenParameter.getContent().get("*/*").getSchema().getRef().pattern, escapedPattern); + Assert.assertEquals(codegenParameter.getContent().get("*/*").getSchema().getRefInfo().getRef().pattern, escapedPattern); // Validate when converting to response ApiResponse response = operation.getResponses().get("200"); CodegenResponse codegenResponse = config.fromResponse(response, "#/paths/~1fake~1StringRegex/post/responses/200"); - Assert.assertEquals(codegenResponse.getContent().get("*/*").getSchema().getRef().getPattern(), escapedPattern); + Assert.assertEquals(codegenResponse.getContent().get("*/*").getSchema().getRefInfo().getRef().getPattern(), escapedPattern); } @Test