mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
This reverts commit d99f46cff9
.
This commit is contained in:
parent
d30fcbabba
commit
78815ba0e0
@ -1046,70 +1046,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
*
|
||||
* @param codegenParameter Codegen parameter
|
||||
*/
|
||||
protected void setParameterExampleValueFromVendorExtensions(CodegenParameter codegenParameter) {
|
||||
if (codegenParameter.vendorExtensions == null || !codegenParameter.vendorExtensions.containsKey("x-example")) {
|
||||
return;
|
||||
}
|
||||
|
||||
codegenParameter.example = Json.pretty(codegenParameter.vendorExtensions.get("x-example"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the example value of the parameter.
|
||||
*
|
||||
* @param codegenParameter Codegen parameter
|
||||
* @param parameter parameter
|
||||
*/
|
||||
protected void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
|
||||
setParameterExampleValueFromVendorExtensions(codegenParameter);
|
||||
if (codegenParameter.example != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parameter.getExample() != null) {
|
||||
codegenParameter.example = parameter.getExample().toString();
|
||||
return;
|
||||
}
|
||||
|
||||
setParameterExampleValue(codegenParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the example value of the parameter.
|
||||
*
|
||||
* @param codegenParameter Codegen parameter
|
||||
* @param schema schema
|
||||
*/
|
||||
protected void setParameterExampleValue(CodegenParameter codegenParameter, Schema schema) {
|
||||
setParameterExampleValueFromVendorExtensions(codegenParameter);
|
||||
if (codegenParameter.example != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (schema.getExample() != null) {
|
||||
codegenParameter.example = schema.getExample().toString();
|
||||
return;
|
||||
}
|
||||
|
||||
setParameterExampleValue(codegenParameter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the example value of the parameter.
|
||||
*
|
||||
* @param codegenParameter Codegen parameter
|
||||
*/
|
||||
protected void setParameterExampleValue(CodegenParameter codegenParameter) {
|
||||
public void setParameterExampleValue(CodegenParameter codegenParameter) {
|
||||
|
||||
// set the example value
|
||||
// if not specified in x-example, generate a default value
|
||||
setParameterExampleValueFromVendorExtensions(codegenParameter);
|
||||
if (codegenParameter.example != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO need to revise how to obtain the example value
|
||||
if (Boolean.TRUE.equals(codegenParameter.isBoolean)) {
|
||||
if (codegenParameter.vendorExtensions != null && codegenParameter.vendorExtensions.containsKey("x-example")) {
|
||||
codegenParameter.example = Json.pretty(codegenParameter.vendorExtensions.get("x-example"));
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isBoolean)) {
|
||||
codegenParameter.example = "true";
|
||||
} else if (Boolean.TRUE.equals(codegenParameter.isLong)) {
|
||||
codegenParameter.example = "789";
|
||||
@ -2799,7 +2743,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// set the parameter excample value
|
||||
// should be overridden by lang codegen
|
||||
setParameterExampleValue(codegenParameter, parameter);
|
||||
setParameterExampleValue(codegenParameter);
|
||||
|
||||
postProcessParameter(codegenParameter);
|
||||
LOGGER.debug("debugging codegenParameter return: " + codegenParameter);
|
||||
@ -4040,7 +3984,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
/**
|
||||
* returns the list of MIME types the APIs can produce
|
||||
*
|
||||
* @param openAPI OpenAPI
|
||||
* @param openAPI
|
||||
* @param operation Operation
|
||||
* @return a set of MIME types
|
||||
*/
|
||||
@ -4266,7 +4210,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
setParameterExampleValue(codegenParameter, propertySchema);
|
||||
setParameterExampleValue(codegenParameter);
|
||||
|
||||
//TODO collectionFormat for form parameter not yet supported
|
||||
//codegenParameter.collectionFormat = getCollectionFormat(propertySchema);
|
||||
@ -4424,7 +4368,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// set the parameter's example value
|
||||
// should be overridden by lang codegen
|
||||
setParameterExampleValue(codegenParameter, schema);
|
||||
setParameterExampleValue(codegenParameter);
|
||||
|
||||
return codegenParameter;
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ public class ModelUtils {
|
||||
|
||||
/**
|
||||
* If a Schema contains a reference to an other Schema with '$ref', returns the referenced Schema or the actual Schema in the other cases.
|
||||
* @param openAPI OpenAPI
|
||||
* @param openAPI
|
||||
* @param schema potentially containing a '$ref'
|
||||
* @return schema without '$ref'
|
||||
*/
|
||||
@ -374,7 +374,7 @@ public class ModelUtils {
|
||||
|
||||
/**
|
||||
* If a RequestBody contains a reference to an other RequestBody with '$ref', returns the referenced RequestBody or the actual RequestBody in the other cases.
|
||||
* @param openAPI OpenAPI
|
||||
* @param openAPI
|
||||
* @param requestBody potentially containing a '$ref'
|
||||
* @return requestBody without '$ref'
|
||||
*/
|
||||
@ -399,7 +399,7 @@ public class ModelUtils {
|
||||
|
||||
/**
|
||||
* If a ApiResponse contains a reference to an other ApiResponse with '$ref', returns the referenced ApiResponse or the actual ApiResponse in the other cases.
|
||||
* @param openAPI OpenAPI
|
||||
* @param openAPI
|
||||
* @param apiResponse potentially containing a '$ref'
|
||||
* @return apiResponse without '$ref'
|
||||
*/
|
||||
|
@ -72,9 +72,9 @@ public class URLPathUtils {
|
||||
|
||||
/**
|
||||
* Return the port, example value <code>8080</code>
|
||||
* @param url URL
|
||||
* @param url
|
||||
* @param defaultPort if the port is not set
|
||||
* @return port
|
||||
* @return
|
||||
*/
|
||||
public static String getPort(URL url, int defaultPort) {
|
||||
return getPort(url, String.valueOf(defaultPort));
|
||||
@ -82,9 +82,9 @@ public class URLPathUtils {
|
||||
|
||||
/**
|
||||
* Return the port, example value <code>8080</code>
|
||||
* @param url URL
|
||||
* @param url
|
||||
* @param defaultPort if the port is not set
|
||||
* @return port
|
||||
* @return
|
||||
*/
|
||||
public static String getPort(URL url, String defaultPort) {
|
||||
if (url == null || url.getPort() == -1) {
|
||||
@ -96,7 +96,7 @@ public class URLPathUtils {
|
||||
|
||||
/**
|
||||
* Return the path, example value <code>/abcdef/xyz</code>
|
||||
* @param url URL
|
||||
* @param url
|
||||
* @param defaultPath if the path is not empty
|
||||
* @return path
|
||||
*/
|
||||
@ -110,7 +110,7 @@ public class URLPathUtils {
|
||||
|
||||
/**
|
||||
* Get the protocol and the host, example value <code>https://www.abcdef.xyz</code>
|
||||
* @param url URL
|
||||
* @param url
|
||||
* @return protocolAndHost
|
||||
*/
|
||||
public static String getProtocolAndHost(URL url) {
|
||||
@ -124,7 +124,7 @@ public class URLPathUtils {
|
||||
|
||||
/**
|
||||
* Return the first complete URL from the OpenAPI specification
|
||||
* @param openAPI OpenAPI
|
||||
* @param openAPI
|
||||
* @return host
|
||||
*/
|
||||
public static String getHost(OpenAPI openAPI) {
|
||||
|
Loading…
Reference in New Issue
Block a user