mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-16 08:31:26 +00:00
added Json schema fields
This commit is contained in:
@@ -6,7 +6,8 @@ import java.util.*;
|
||||
|
||||
public class CodegenOperation {
|
||||
public Boolean hasConsumes, hasProduces, hasParams, returnTypeIsPrimitive,
|
||||
returnSimpleType, subresourceOperation, isMapContainer, isListContainer;
|
||||
returnSimpleType, subresourceOperation, isMapContainer, isListContainer,
|
||||
hasMore = Boolean.TRUE;
|
||||
public String path, operationId, returnType, httpMethod, returnBaseType,
|
||||
returnContainer, summary, notes, baseName, defaultResponse;
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ public class CodegenParameter {
|
||||
public Boolean isFormParam, isQueryParam, isPathParam, isHeaderParam,
|
||||
isCookieParam, isBodyParam, isFile, notFile, hasMore, isContainer, secondaryParam;
|
||||
public String baseName, paramName, dataType, collectionFormat, description, baseType;
|
||||
public String jsonSchema;
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -31,6 +33,7 @@ public class CodegenParameter {
|
||||
output.isCookieParam = this.isCookieParam;
|
||||
output.isBodyParam = this.isBodyParam;
|
||||
output.required = this.required;
|
||||
output.jsonSchema = this.jsonSchema;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public class CodegenProperty {
|
||||
/** A free-form property to include an example of an instance for this schema. */
|
||||
public String example;
|
||||
|
||||
public String jsonSchema;
|
||||
public Double minimum, maximum, exclusiveMinimum, exclusiveMaximum;
|
||||
public Boolean hasMore = null, required = null, secondaryParam = null;
|
||||
public Boolean isPrimitiveType, isContainer, isNotContainer;
|
||||
|
||||
@@ -11,5 +11,6 @@ public class CodegenResponse {
|
||||
public Boolean primitiveType;
|
||||
public Boolean isMapContainer;
|
||||
public Boolean isListContainer;
|
||||
Object schema;
|
||||
public Object schema;
|
||||
public String jsonSchema;
|
||||
}
|
||||
@@ -476,9 +476,9 @@ public class DefaultCodegen {
|
||||
property.setter = "set" + getterAndSetterCapitalize(name);
|
||||
property.example = p.getExample();
|
||||
property.defaultValue = toDefaultValue(p);
|
||||
property.jsonSchema = Json.pretty(p);
|
||||
|
||||
String type = getSwaggerType(p);
|
||||
|
||||
if(p instanceof AbstractNumericProperty) {
|
||||
AbstractNumericProperty np = (AbstractNumericProperty) p;
|
||||
property.minimum = np.getMinimum();
|
||||
@@ -640,7 +640,6 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
|
||||
|
||||
Response methodResponse = findMethodResponse(operation.getResponses());
|
||||
CodegenResponse methodCodegenResponse = null;
|
||||
|
||||
@@ -758,6 +757,7 @@ public class DefaultCodegen {
|
||||
r.message = response.getDescription();
|
||||
r.schema = response.getSchema();
|
||||
r.examples = toExamples(response.getExamples());
|
||||
r.jsonSchema = Json.pretty(response);
|
||||
|
||||
if (r.schema != null) {
|
||||
Property responseProperty = response.getSchema();
|
||||
@@ -800,6 +800,7 @@ public class DefaultCodegen {
|
||||
p.baseName = param.getName();
|
||||
p.description = param.getDescription();
|
||||
p.required = param.getRequired();
|
||||
p.jsonSchema = Json.pretty(param);
|
||||
|
||||
if(param instanceof SerializableParameter) {
|
||||
SerializableParameter qp = (SerializableParameter) param;
|
||||
|
||||
@@ -65,8 +65,15 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
else
|
||||
hostBuilder.append("https://");
|
||||
hostBuilder.append(swagger.getHost()).append(swagger.getBasePath());
|
||||
String contextPath = swagger.getBasePath();
|
||||
if(swagger.getHost() != null)
|
||||
hostBuilder.append(swagger.getHost());
|
||||
else
|
||||
hostBuilder.append("localhost");
|
||||
if(swagger.getBasePath() != null)
|
||||
hostBuilder.append(swagger.getBasePath());
|
||||
else
|
||||
hostBuilder.append("/");
|
||||
String contextPath = swagger.getBasePath() == null ? "/" : swagger.getBasePath();
|
||||
String basePath = hostBuilder.toString();
|
||||
|
||||
|
||||
@@ -119,7 +126,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
operation.putAll(config.additionalProperties());
|
||||
operation.put("classname", config.toApiName(tag));
|
||||
operation.put("classVarName", config.toApiVarName(tag));
|
||||
allOperations.add(operation);
|
||||
allOperations.add(new HashMap<String, Object>(operation));
|
||||
for(String templateName : config.apiTemplateFiles().keySet()) {
|
||||
String suffix = config.apiTemplateFiles().get(templateName);
|
||||
String filename = config.apiFileFolder() +
|
||||
@@ -319,6 +326,14 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
operations.put("imports", imports);
|
||||
config.postProcessOperations(operations);
|
||||
if(objs.size() > 0) {
|
||||
List<CodegenOperation> os = (List<CodegenOperation>) objs.get("operation");
|
||||
|
||||
if(os != null && os.size() > 0) {
|
||||
CodegenOperation op = os.get(os.size() - 1);
|
||||
op.hasMore = null;
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user