diff --git a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java index b5750a3063..4a5c2780d8 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java +++ b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java @@ -1077,7 +1077,7 @@ private static String getTypeOfSchema(Schema schema) { } else if (schema instanceof BinarySchema) { return SchemaTypeUtil.BINARY_FORMAT; } else if (schema instanceof FileSchema) { - return "file"; // FIXME: this type does not exist in the OpenAPI 3.0 specification + return SchemaTypeUtil.BINARY_FORMAT; } else if (schema instanceof BooleanSchema) { return SchemaTypeUtil.BOOLEAN_TYPE; } else if (schema instanceof DateSchema) { diff --git a/src/main/java/io/swagger/codegen/v3/generators/html/HtmlSchemaHandler.java b/src/main/java/io/swagger/codegen/v3/generators/html/HtmlSchemaHandler.java new file mode 100644 index 0000000000..8748a79208 --- /dev/null +++ b/src/main/java/io/swagger/codegen/v3/generators/html/HtmlSchemaHandler.java @@ -0,0 +1,135 @@ +package io.swagger.codegen.v3.generators.html; + +import io.swagger.codegen.v3.CodegenModel; +import io.swagger.codegen.v3.CodegenModelFactory; +import io.swagger.codegen.v3.CodegenModelType; +import io.swagger.codegen.v3.CodegenProperty; +import io.swagger.codegen.v3.generators.DefaultCodegenConfig; +import io.swagger.codegen.v3.generators.SchemaHandler; +import io.swagger.codegen.v3.generators.util.OpenAPIUtil; +import io.swagger.v3.oas.models.media.ComposedSchema; +import io.swagger.v3.oas.models.media.Schema; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +public class HtmlSchemaHandler extends SchemaHandler { + + public HtmlSchemaHandler(DefaultCodegenConfig codegenConfig) { + super(codegenConfig); + } + + + public void createCodegenModel(ComposedSchema composedProperty, CodegenProperty codegenProperty) { + final List oneOf = composedProperty.getOneOf(); + final List anyOf = composedProperty.getAnyOf(); + + if (oneOf != null && !oneOf.isEmpty()) { + if (!hasNonObjectSchema(oneOf)) { + final CodegenModel oneOfModel = createFromOneOfSchemas(oneOf); + codegenProperty.vendorExtensions.put("oneOf-model", oneOfModel); + } + } + if (anyOf != null && !anyOf.isEmpty()) { + if (!hasNonObjectSchema(anyOf)) { + final CodegenModel anyOfModel = createFromOneOfSchemas(anyOf); + codegenProperty.vendorExtensions.put("anyOf-model", anyOfModel); + } + } + + } + + public void configureComposedModelFromSchemaItems(CodegenModel codegenModel, ComposedSchema items) { + List oneOfList = items.getOneOf(); + if (oneOfList != null && !oneOfList.isEmpty()){ + String name = "OneOf" + codegenModel.name + "Items"; + final CodegenModel oneOfModel = createComposedModel(name); + // setting name to be used as instance type on composed model. + items.addExtension("x-model-name", codegenConfig.toModelName(name)); + + final List modelNames = new ArrayList<>(); + for (Schema interfaceSchema : oneOfList) { + if (StringUtils.isNotBlank(interfaceSchema.get$ref())) { + String schemaName = OpenAPIUtil.getSimpleRef(interfaceSchema.get$ref()); + modelNames.add(codegenConfig.toModelName(schemaName)); + } + } + oneOfModel.vendorExtensions.put("x-model-names", modelNames); + if (!modelNames.isEmpty()) { + codegenModel.vendorExtensions.put("oneOf-model", oneOfModel); + } + } + List anyOfList = items.getAnyOf(); + if (anyOfList != null && !anyOfList.isEmpty()){ + String name = "AnyOf" + codegenModel.name + "Items"; + final CodegenModel anyOfModel = createComposedModel(name); + items.addExtension("x-model-name", codegenConfig.toModelName(name)); + + final List modelNames = new ArrayList<>(); + for (Schema interfaceSchema : anyOfList) { + if (StringUtils.isNotBlank(interfaceSchema.get$ref())) { + String schemaName = OpenAPIUtil.getSimpleRef(interfaceSchema.get$ref()); + modelNames.add(codegenConfig.toModelName(schemaName)); + } + } + anyOfModel.vendorExtensions.put("x-model-names", modelNames); + if (!modelNames.isEmpty()) { + codegenModel.vendorExtensions.put("anyOf-model", anyOfModel); + } + } + } + + public void configureOneOfModel(CodegenModel codegenModel, List oneOf) { + // no ops for html generator + } + + public void configureAnyOfModel(CodegenModel codegenModel, List anyOf) { + // no ops for html generator + } + + public void configureOneOfModelFromProperty(CodegenProperty codegenProperty, CodegenModel codegenModel) { + // no ops for html generator + } + + public void configureAnyOfModelFromProperty(CodegenProperty codegenProperty, CodegenModel codegenModel) { + // no ops for html generator + } + + private CodegenModel createFromOneOfSchemas(List schemas) { + final CodegenModel codegenModel = CodegenModelFactory.newInstance(CodegenModelType.MODEL); + final List modelNames = new ArrayList<>(); + + for (Schema interfaceSchema : schemas) { + if (StringUtils.isNotBlank(interfaceSchema.get$ref())) { + String schemaName = OpenAPIUtil.getSimpleRef(interfaceSchema.get$ref()); + modelNames.add(codegenConfig.toModelName(schemaName)); + } + } + codegenModel.vendorExtensions.put("x-model-names", modelNames); + return codegenModel; + } + + private CodegenModel createComposedModel(String name) { + final CodegenModel composedModel = CodegenModelFactory.newInstance(CodegenModelType.MODEL); + this.configureModel(composedModel, name); + return composedModel; + } + + private void configureModel(CodegenModel codegenModel, String name) { + codegenModel.name = name; + codegenModel.classname = codegenConfig.toModelName(name); + codegenModel.classVarName = codegenConfig.toVarName(name); + codegenModel.classFilename = codegenConfig.toModelFilename(name); + codegenModel.vendorExtensions.put("x-is-composed-model", Boolean.TRUE); + } + + private boolean hasNonObjectSchema(List schemas) { + for (Schema schema : schemas) { + if (!codegenConfig.isObjectSchema(schema)) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/io/swagger/codegen/v3/generators/html/StaticHtmlCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/html/StaticHtmlCodegen.java index 2a50d45985..d6f8ee140b 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/html/StaticHtmlCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/html/StaticHtmlCodegen.java @@ -32,6 +32,7 @@ public class StaticHtmlCodegen extends DefaultCodegenConfig { public StaticHtmlCodegen() { super(); + schemaHandler = new HtmlSchemaHandler(this); outputFolder = "docs"; defaultIncludes = new HashSet(); @@ -155,7 +156,7 @@ public String escapeUnsafeCharacters(String input) { /** * Convert Markdown text to HTML - * + * * @param input * text in Markdown; may be null. * @return the text, converted to Markdown. For null input, "" is returned. diff --git a/src/main/resources/handlebars/Java/api_doc.mustache b/src/main/resources/handlebars/Java/api_doc.mustache index c60dc02efe..bb10129cbe 100644 --- a/src/main/resources/handlebars/Java/api_doc.mustache +++ b/src/main/resources/handlebars/Java/api_doc.mustache @@ -63,7 +63,7 @@ try { {{^parameters}}This endpoint does not need any parameter.{{/parameters}}{{#parameters}}{{#@last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/@last}}{{/parameters}} -{{#parameters}} **{{paramName}}** | {{#is this 'primitive-type'}}**{{dataType}}**{{/is}}{{#isNot this 'primitive-type'}}{{#is this 'file'}}**{{dataType}}**{{/is}}{{#isNot this 'file'}}[**{{dataType}}**]({{baseType}}.md){{/isNot}}{{/isNot}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^@last}}, {{/@last}}{{/values}}]{{/allowableValues}} +{{#parameters}} **{{paramName}}** | {{#is this 'primitive-type'}}**{{dataType}}**{{/is}}{{#isNot this 'primitive-type'}}{{#isBinary}}**{{dataType}}**{{/isBinary}}{{^isBinary}}[**{{dataType}}**]({{baseType}}.md){{/isBinary}}{{/isNot}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^@last}}, {{/@last}}{{/values}}]{{/allowableValues}} {{/parameters}} ### Return type diff --git a/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache b/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache index 7e0a91627f..830bac6037 100644 --- a/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/resttemplate/api.mustache @@ -103,7 +103,7 @@ public class {{classname}} { {{#hasFormParams}} {{#formParams}} if ({{paramName}} != null) - {{localVariablePrefix}}formParams.add("{{baseName}}", {{#is this 'file'}}new FileSystemResource({{paramName}}){{/is}}{{#isNot this 'file'}}{{paramName}}{{/isNot}}); + {{localVariablePrefix}}formParams.add("{{baseName}}", {{#is this 'binary'}}new FileSystemResource({{paramName}}){{/is}}{{#isNot this 'binary'}}{{paramName}}{{/isNot}}); {{/formParams}} {{/hasFormParams}} diff --git a/src/main/resources/handlebars/Java/libraries/retrofit/formParams.mustache b/src/main/resources/handlebars/Java/libraries/retrofit/formParams.mustache index 0bc9ea5159..0bfdce65cd 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit/formParams.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit/formParams.mustache @@ -1 +1 @@ -{{~#is this 'form-param'}}{{#isNot this 'file'}}{{#is ../this 'multipart'}}@retrofit.http.Part{{/is}}{{#isNot ../this 'multipart'}}@retrofit.http.Field{{/isNot}}("{{baseName}}") {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}}{{#is ../this 'multipart'}}@retrofit.http.Part{{/is}}{{#isNot ../this 'multipart'}}@retrofit.http.Field{{/isNot}}("{{baseName}}") TypedFile {{paramName}}{{/is}}{{/is}} \ No newline at end of file +{{~#is this 'form-param'}}{{#isNot this 'binary'}}{{#is ../this 'multipart'}}@retrofit.http.Part{{/is}}{{#isNot ../this 'multipart'}}@retrofit.http.Field{{/isNot}}("{{baseName}}") {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}}{{#is ../this 'multipart'}}@retrofit.http.Part{{/is}}{{#isNot ../this 'multipart'}}@retrofit.http.Field{{/isNot}}("{{baseName}}") TypedFile {{paramName}}{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/Java/libraries/retrofit2/formParams.mustache b/src/main/resources/handlebars/Java/libraries/retrofit2/formParams.mustache index b141e939b2..0b58db0b40 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit2/formParams.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit2/formParams.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{#is this 'multipart'}}@retrofit2.http.Part{{/is}}{{#isNot this 'multipart'}}@retrofit2.http.Field{{/isNot}}("{{baseName}}") {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}}{{#is this 'multipart'}}@retrofit2.http.Part{{/is}}{{#isNot this 'multipart'}}@retrofit2.http.Field{{/isNot}}{{#usePlayWS}} okhttp3.MultipartBody.Part {{/usePlayWS}}{{^usePlayWS}}("{{baseName}}\"; filename=\"{{baseName}}") RequestBody {{/usePlayWS}}{{paramName}}{{/is}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{#is this 'multipart'}}@retrofit2.http.Part{{/is}}{{#isNot this 'multipart'}}@retrofit2.http.Field{{/isNot}}("{{baseName}}") {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}}{{#is this 'multipart'}}@retrofit2.http.Part{{/is}}{{#isNot this 'multipart'}}@retrofit2.http.Field{{/isNot}}{{#usePlayWS}} okhttp3.MultipartBody.Part {{/usePlayWS}}{{^usePlayWS}}("{{baseName}}\"; filename=\"{{baseName}}") RequestBody {{/usePlayWS}}{{paramName}}{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaInflector/formParams.mustache b/src/main/resources/handlebars/JavaInflector/formParams.mustache index ae90ae4c74..2b68f2fc24 100644 --- a/src/main/resources/handlebars/JavaInflector/formParams.mustache +++ b/src/main/resources/handlebars/JavaInflector/formParams.mustache @@ -1 +1 @@ - {{#is this 'form-param'}}{{#notFile}}{{{dataType}}} {{paramName}}{{/notFile}}{{#is this 'file'}}FormDataContentDisposition fileDetail{{/is}}{{/is}} \ No newline at end of file + {{#is this 'form-param'}}{{#isNot this 'binary'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}}FormDataContentDisposition fileDetail{{/is}}{{/is}} diff --git a/src/main/resources/handlebars/JavaJaxRS/api.mustache b/src/main/resources/handlebars/JavaJaxRS/api.mustache index 66548c9082..8a4a56312d 100644 --- a/src/main/resources/handlebars/JavaJaxRS/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/api.mustache @@ -106,7 +106,7 @@ public class {{classname}} { {{/useOas2}} public Response {{nickname}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}},{{/parameters}}@Context SecurityContext securityContext) throws NotFoundException { - return delegate.{{nickname}}({{#parameters}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/parameters}}securityContext); + return delegate.{{nickname}}({{#parameters}}{{#isBinary}}{{paramName}}InputStream, {{paramName}}Detail{{/isBinary}}{{^isBinary}}{{paramName}}{{/isBinary}},{{/parameters}}securityContext); } {{/contents}} {{/operation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/api.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/api.mustache index 1fa6183916..ab7a73c029 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/api.mustache @@ -79,7 +79,7 @@ public class {{classname}} { @ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{^vendorExtensions.x-java-is-response-void}}, content = @Content({{^containerType}}schema = @Schema(implementation = {{{baseType}}}.class)){{/containerType}}{{#containerType}}array = @ArraySchema(schema = @Schema(implementation = {{{baseType}}}.class))){{/containerType}}{{/vendorExtensions.x-java-is-response-void}}){{#hasMore}},{{/hasMore}}{{/responses}} }) {{/useOas2}} public Response {{nickname}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{/parameters}}) { - return delegate.{{nickname}}({{#parameters}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}, {{/parameters}}securityContext); + return delegate.{{nickname}}({{#parameters}}{{#isBinary}}{{paramName}}InputStream, {{paramName}}Detail{{/isBinary}}{{^isBinary}}{{paramName}}{{/isBinary}}, {{/parameters}}securityContext); } {{/contents}} {{/operation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/formParams.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/formParams.mustache index 362ebd9bb3..44953d477e 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/formParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/formParams.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}@Multipart(value = "{{baseName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}} @Multipart(value = "{{baseName}}"{{^required}}, required = false{{/required}}) InputStream {{paramName}}InputStream, @Multipart(value = "{{baseName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}@Multipart(value = "{{baseName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}} @Multipart(value = "{{baseName}}"{{^required}}, required = false{{/required}}) InputStream {{paramName}}InputStream, @Multipart(value = "{{baseName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/serviceFormParams.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/serviceFormParams.mustache index d5294a8b96..4bf0ae7c29 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/serviceFormParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/serviceFormParams.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}}InputStream {{paramName}}InputStream, Attachment {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}}InputStream {{paramName}}InputStream, Attachment {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/api_test.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/api_test.mustache index 5194af8457..e265b96996 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/api_test.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/api_test.mustache @@ -113,7 +113,7 @@ public class {{classname}}Test { @Test public void {{operationId}}Test() { {{#parameters}} - {{^isFile}}{{{dataType}}} {{paramName}} = null;{{/isFile}}{{#isFile}}org.apache.cxf.jaxrs.ext.multipart.Attachment {{paramName}} = null;{{/isFile}} + {{^isBinary}}{{{dataType}}} {{paramName}} = null;{{/isBinary}}{{#isBinary}}org.apache.cxf.jaxrs.ext.multipart.Attachment {{paramName}} = null;{{/isBinary}} {{/parameters}} //{{^vendorExtensions.x-java-is-response-void}}{{>returnTypes}} response = {{/vendorExtensions.x-java-is-response-void}}api.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); {{^vendorExtensions.x-java-is-response-void}}//assertNotNull(response);{{/vendorExtensions.x-java-is-response-void}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/formParams.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/formParams.mustache index 3a58a53af4..c3039d77ba 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/formParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/formParams.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}@Multipart(value = "{{baseName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}} @Multipart(value = "{{baseName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}@Multipart(value = "{{baseName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}} @Multipart(value = "{{baseName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/formParamsImpl.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/formParamsImpl.mustache index 2c42609fc8..1d683f5b40 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/formParamsImpl.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/formParamsImpl.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}} Attachment {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}} Attachment {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/di/api.mustache b/src/main/resources/handlebars/JavaJaxRS/di/api.mustache index 6ac2b09fbf..bc714ba145 100644 --- a/src/main/resources/handlebars/JavaJaxRS/di/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/di/api.mustache @@ -88,7 +88,7 @@ public class {{classname}} { {{/useOas2}} public Response {{nickname}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}},{{/parameters}}@Context SecurityContext securityContext) throws NotFoundException { - return delegate.{{nickname}}({{#parameters}}{{#isFile}}{{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/parameters}}securityContext); + return delegate.{{nickname}}({{#parameters}}{{#isBinary}}{{paramName}}InputStream, {{paramName}}Detail{{/isBinary}}{{^isBinary}}{{paramName}}{{/isBinary}},{{/parameters}}securityContext); } {{/contents}} {{/operation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/formParams.mustache b/src/main/resources/handlebars/JavaJaxRS/formParams.mustache index 0080b9b373..3843716cde 100644 --- a/src/main/resources/handlebars/JavaJaxRS/formParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/formParams.mustache @@ -1,2 +1,2 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{#useOas2}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{#vendorExtensions.x-multipart}}@FormDataParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}} {{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{/useOas2}}{{^useOas2}}@Parameter(description = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{#vendorExtensions.x-multipart}}@FormDataParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}} {{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{/useOas2}}{{/isNot}}{{#is this 'file'}}@FormDataParam("{{baseName}}") InputStream {{paramName}}InputStream, +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{#useOas2}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{#vendorExtensions.x-multipart}}@FormDataParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}} {{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{/useOas2}}{{^useOas2}}@Parameter(description = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{#vendorExtensions.x-multipart}}@FormDataParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}} {{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{/useOas2}}{{/isNot}}{{#is this 'binary'}}@FormDataParam("{{baseName}}") InputStream {{paramName}}InputStream, @FormDataParam("{{baseName}}") FormDataContentDisposition {{paramName}}Detail{{/is}}{{/is}} diff --git a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/api.mustache b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/api.mustache index 912b7a4ecb..31a4f8e894 100644 --- a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/api.mustache @@ -58,7 +58,7 @@ public class {{classname}} { {{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}, {{/parameters}}@Context SecurityContext securityContext) throws NotFoundException { - return delegate.{{nickname}}({{#parameters}}{{#isFile}} {{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/parameters}}securityContext); + return delegate.{{nickname}}({{#parameters}}{{#isBinary}} {{paramName}}InputStream, {{paramName}}Detail{{/isBinary}}{{^isBinary}}{{paramName}}{{/isBinary}},{{/parameters}}securityContext); } {{/contents}} {{/operation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/formParams.mustache b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/formParams.mustache index 9d505ebea4..d9b7151f76 100644 --- a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/formParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/formParams.mustache @@ -1,2 +1,2 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{#isNot this 'multipart'}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{/isNot}}{{#is this 'multipart'}}@FormDataParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/is}}{{#isNot this 'multipart'}} {{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isNot}}{{/isNot}}{{#is this 'file'}}@FormDataParam("{{baseName}}") InputStream inputStream, +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{#isNot this 'multipart'}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}){{/isNot}}{{#is this 'multipart'}}@FormDataParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/is}}{{#isNot this 'multipart'}} {{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isNot}}{{/isNot}}{{#is this 'binary'}}@FormDataParam("{{baseName}}") InputStream inputStream, @FormDataParam("{{baseName}}") FormDataContentDisposition fileDetail{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/formParams.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/formParams.mustache index 8039a30433..bca3affc3d 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/formParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/formParams.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{#useOas2}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/useOas2}}{{^useOas2}}@Parameter(description = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/useOas2}}{{/isNot}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{#useOas2}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/useOas2}}{{^useOas2}}@Parameter(description = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/useOas2}}{{/isNot}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/serviceFormParams.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/serviceFormParams.mustache index 5bc6d7c5d4..72fe3e7ebe 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/serviceFormParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/serviceFormParams.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}}FormDataContentDisposition fileDetail{{/is}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}}FormDataContentDisposition fileDetail{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/formParams.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/formParams.mustache index 8039a30433..bca3affc3d 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/formParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/formParams.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{#useOas2}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/useOas2}}{{^useOas2}}@Parameter(description = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/useOas2}}{{/isNot}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{#useOas2}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/useOas2}}{{^useOas2}}@Parameter(description = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/useOas2}}{{/isNot}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/serviceFormParams.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/serviceFormParams.mustache index 5bc6d7c5d4..72fe3e7ebe 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/serviceFormParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/serviceFormParams.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}}FormDataContentDisposition fileDetail{{/is}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}}FormDataContentDisposition fileDetail{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/serviceFormParams.mustache b/src/main/resources/handlebars/JavaJaxRS/serviceFormParams.mustache index a88f3c0a18..06e6c0d0fd 100644 --- a/src/main/resources/handlebars/JavaJaxRS/serviceFormParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/serviceFormParams.mustache @@ -1 +1 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}}InputStream {{paramName}}InputStream, FormDataContentDisposition {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file +{{#is this 'form-param'}}{{#isNot this 'binary'}}{{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}}InputStream {{paramName}}InputStream, FormDataContentDisposition {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaJaxRS/spec/formParams.mustache b/src/main/resources/handlebars/JavaJaxRS/spec/formParams.mustache index b29f25b3ed..aeb477b05f 100644 --- a/src/main/resources/handlebars/JavaJaxRS/spec/formParams.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/spec/formParams.mustache @@ -1,2 +1,2 @@ -{{#is this 'form-param'}}{{#isNot this 'file'}}@FormParam(value = "{{baseName}}") {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'file'}} @FormParam(value = "{{baseName}}") InputStream {{paramName}}InputStream, +{{#is this 'form-param'}}{{#isNot this 'binary'}}@FormParam(value = "{{baseName}}") {{{dataType}}} {{paramName}}{{/isNot}}{{#is this 'binary'}} @FormParam(value = "{{baseName}}") InputStream {{paramName}}InputStream, @FormParam(value = "{{baseName}}") Attachment {{paramName}}Detail{{/is}}{{/is}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring/api.mustache b/src/main/resources/handlebars/JavaSpring/api.mustache index dc03180054..4c626c1508 100644 --- a/src/main/resources/handlebars/JavaSpring/api.mustache +++ b/src/main/resources/handlebars/JavaSpring/api.mustache @@ -108,7 +108,7 @@ public interface {{classname}} { } // Override this method - default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/parameters}}) { + default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isBinary}}{{{dataType}}}{{/isBinary}}{{#isBinary}}MultipartFile{{/isBinary}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/parameters}}) { {{/delegate-method}} {{^isDelegate}} if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { diff --git a/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache b/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache index ee740a321c..de0a9d809b 100644 --- a/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache +++ b/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache @@ -63,7 +63,7 @@ public interface {{classname}}Delegate { /** * @see {{classname}}#{{operationId}} */ - {{#defaultInterfaces}}default {{/defaultInterfaces}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}} {{>optionalDataType}} {{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, + {{#defaultInterfaces}}default {{/defaultInterfaces}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isBinary}} {{>optionalDataType}} {{/isBinary}}{{#isBinary}}MultipartFile{{/isBinary}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}){{^defaultInterfaces}};{{/defaultInterfaces}}{{#defaultInterfaces}} { if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { {{#examples}} diff --git a/src/main/resources/handlebars/JavaSpring/formParams.mustache b/src/main/resources/handlebars/JavaSpring/formParams.mustache index f9c3e502b8..b91da48cfe 100644 --- a/src/main/resources/handlebars/JavaSpring/formParams.mustache +++ b/src/main/resources/handlebars/JavaSpring/formParams.mustache @@ -1 +1 @@ -{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^@last}}, {{/@last}}{{#@last}}{{/@last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file +{{#isFormParam}}{{^isBinary}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^@last}}, {{/@last}}{{#@last}}{{/@last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isBinary}}{{#isBinary}}@ApiParam(value = "file detail") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart("file") MultipartFile {{baseName}}{{/isBinary}}{{/isFormParam}} diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/api_test.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/api_test.mustache index 6558eb235c..7dcdf57563 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/api_test.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/api_test.mustache @@ -28,12 +28,12 @@ public class {{classname}}ControllerIntegrationTest { @Test public void {{operationId}}Test() throws Exception { {{#parameters}} - {{^isFile}} + {{^isBinary}} {{{dataType}}} {{paramName}} = {{{example}}}; - {{/isFile}} - {{#isFile}} + {{/isBinary}} + {{#isBinary}} org.springframework.web.multipart.MultipartFile {{paramName}} = null; - {{/isFile}} + {{/isBinary}} {{/parameters}} ResponseEntity<{{>returnTypes}}> responseEntity = api.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/api_test.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/api_test.mustache index 0723a652b4..b9cf5a2773 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/api_test.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/api_test.mustache @@ -29,12 +29,12 @@ private {{classname}} api; @Test public void {{operationId}}Test() throws Exception { {{#parameters}} - {{^isFile}} + {{^isBinary}} {{{dataType}}} {{paramName}} = {{{example}}}; - {{/isFile}} - {{#isFile}} + {{/isBinary}} + {{#isBinary}} org.springframework.web.multipart.MultipartFile {{paramName}} = null; - {{/isFile}} + {{/isBinary}} {{/parameters}} api.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); // todo: add verifications diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/formParams.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/formParams.mustache index bd2cb8bb64..4fc0ac6d4f 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/formParams.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/formParams.mustache @@ -1 +1 @@ -{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestParam("{{baseName}}") MultipartFile {{paramName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file +{{#isFormParam}}{{^isBinary}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isBinary}}{{#isBinary}}@ApiParam(value = "file detail") @RequestParam("{{baseName}}") MultipartFile {{paramName}}{{/isBinary}}{{/isFormParam}} diff --git a/src/main/resources/handlebars/csharp-dotnet2/api.mustache b/src/main/resources/handlebars/csharp-dotnet2/api.mustache index ff0445d6d9..ea612d5c67 100644 --- a/src/main/resources/handlebars/csharp-dotnet2/api.mustache +++ b/src/main/resources/handlebars/csharp-dotnet2/api.mustache @@ -107,7 +107,7 @@ namespace {{apiPackage}} {{/queryParams}} {{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter {{/headerParams}} - {{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}} + {{#formParams}}if ({{paramName}} != null) {{#isBinary}}fileParams.Add("{{baseName}}", ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isBinary}}{{^isBinary}}formParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // form parameter{{/isBinary}} {{/formParams}} {{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter {{/bodyParam}} diff --git a/src/main/resources/handlebars/csharp-dotnet2/api_doc.mustache b/src/main/resources/handlebars/csharp-dotnet2/api_doc.mustache index 3e51f10b5c..c8625885ba 100644 --- a/src/main/resources/handlebars/csharp-dotnet2/api_doc.mustache +++ b/src/main/resources/handlebars/csharp-dotnet2/api_doc.mustache @@ -77,7 +77,7 @@ namespace Example {{^parameters}}This endpoint does not need any parameter.{{/parameters}}{{#parameters}}{{#@last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/@last}}{{/parameters}} -{{#parameters}} **{{paramName}}** | {{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{{dataType}}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{#parameters}} **{{paramName}}** | {{#isBinary}}**{{{dataType}}}**{{/isBinary}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isBinary}}[**{{{dataType}}}**]({{baseType}}.md){{/isBinary}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} {{/parameters}} ### Return type diff --git a/src/main/resources/handlebars/csharp/api.mustache b/src/main/resources/handlebars/csharp/api.mustache index e720fcd5d6..123180a529 100644 --- a/src/main/resources/handlebars/csharp/api.mustache +++ b/src/main/resources/handlebars/csharp/api.mustache @@ -254,7 +254,7 @@ namespace {{packageName}}.{{apiPackage}} {{/headerParams}} {{#isForm}} {{#formParams}} - if ({{paramName}} != null) {{#isFile}}localVarFileParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}localVarFormParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}} + if ({{paramName}} != null) {{#isBinary}}localVarFileParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isBinary}}{{^isBinary}}localVarFormParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToString({{paramName}})); // form parameter{{/isBinary}} {{/formParams}} {{/isForm}} {{^isForm}} @@ -400,7 +400,7 @@ namespace {{packageName}}.{{apiPackage}} {{/headerParams}} {{#isForm}} {{#formParams}} - if ({{paramName}} != null) {{#isFile}}localVarFileParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}localVarFormParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}} + if ({{paramName}} != null) {{#isBinary}}localVarFileParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isBinary}}{{^isBinary}}localVarFormParams.Add("{{baseName}}", this.Configuration.ApiClient.ParameterToString({{paramName}})); // form parameter{{/isBinary}} {{/formParams}} {{/isForm}} {{^isForm}} diff --git a/src/main/resources/handlebars/csharp/api_doc.mustache b/src/main/resources/handlebars/csharp/api_doc.mustache index 4fe2a2c4b9..4ed1ca0fdb 100644 --- a/src/main/resources/handlebars/csharp/api_doc.mustache +++ b/src/main/resources/handlebars/csharp/api_doc.mustache @@ -85,7 +85,7 @@ namespace Example {{^parameters}}This endpoint does not need any parameter.{{/parameters}}{{#parameters}}{{#@last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/@last}}{{/parameters}} -{{#parameters}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{#isContainer}}{{baseType}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{#parameters}} **{{paramName}}** | {{#isBinary}}**{{dataType}}**{{/isBinary}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isBinary}}[**{{dataType}}**]({{#isContainer}}{{baseType}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}.md){{/isBinary}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} {{/parameters}} ### Return type diff --git a/src/main/resources/handlebars/htmlDocs/index.mustache b/src/main/resources/handlebars/htmlDocs/index.mustache index 3130275287..59b27c891a 100644 --- a/src/main/resources/handlebars/htmlDocs/index.mustache +++ b/src/main/resources/handlebars/htmlDocs/index.mustache @@ -174,6 +174,36 @@ {{#example}}
example: {{example}}
{{/example}} + {{#vendorExtensions.oneOf-model}} +
oneOf: + {{#vendorExtensions.x-model-names}} + {{this}}    + {{/vendorExtensions.x-model-names}} +
+ {{/vendorExtensions.oneOf-model}} + {{#vendorExtensions.anyOf-model}} +
anyOf: + {{#vendorExtensions.x-model-names}} + {{this}}    + {{/vendorExtensions.x-model-names}} +
+ {{/vendorExtensions.anyOf-model}} + {{#items}} + {{#vendorExtensions.oneOf-model}} +
items oneOf: + {{#vendorExtensions.x-model-names}} + {{this}}    + {{/vendorExtensions.x-model-names}} +
+ {{/vendorExtensions.oneOf-model}} + {{#vendorExtensions.anyOf-model}} +
items anyOf: + {{#vendorExtensions.x-model-names}} + {{this}}    + {{/vendorExtensions.x-model-names}} +
+ {{/vendorExtensions.anyOf-model}} + {{/items}} {{/vars}} diff --git a/src/main/resources/handlebars/kotlin-client/api_doc.mustache b/src/main/resources/handlebars/kotlin-client/api_doc.mustache index b390671f68..0ade39e394 100644 --- a/src/main/resources/handlebars/kotlin-client/api_doc.mustache +++ b/src/main/resources/handlebars/kotlin-client/api_doc.mustache @@ -46,7 +46,7 @@ try { {{^parameters}}This endpoint does not need any parameter.{{/parameters}}{{#parameters}}{{#@last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/@last}}{{/parameters}} -{{#parameters}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^@last}}, {{/@last}}{{/values}}]{{/allowableValues}} +{{#parameters}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isBinary}}**{{dataType}}**{{/isBinary}}{{^isBinary}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isBinary}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^@last}}, {{/@last}}{{/values}}]{{/allowableValues}} {{/parameters}} ### Return type diff --git a/src/main/resources/handlebars/kotlin-server/api_doc.mustache b/src/main/resources/handlebars/kotlin-server/api_doc.mustache index eb212243df..0ade39e394 100644 --- a/src/main/resources/handlebars/kotlin-server/api_doc.mustache +++ b/src/main/resources/handlebars/kotlin-server/api_doc.mustache @@ -46,7 +46,7 @@ try { {{^parameters}}This endpoint does not need any parameter.{{/parameters}}{{#parameters}}{{#@last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/@last}}{{/parameters}} -{{#parameters}} **{{paramName}}** | {{#isPrimitiveType}}}**{{dataType}}**{{/is}}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isFile}}{{/isPrimitiveType}}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^@last}}, {{/@last}}{{/values}}]{{/allowableValues}} +{{#parameters}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isBinary}}**{{dataType}}**{{/isBinary}}{{^isBinary}}{{#generateModelDocs}}[**{{dataType}}**]({{baseType}}.md){{/generateModelDocs}}{{^generateModelDocs}}**{{dataType}}**{{/generateModelDocs}}{{/isBinary}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^@last}}, {{/@last}}{{/values}}]{{/allowableValues}} {{/parameters}} ### Return type diff --git a/src/main/resources/handlebars/nodejs/index.mustache b/src/main/resources/handlebars/nodejs/index.mustache index ad02896cf1..491f5e3091 100644 --- a/src/main/resources/handlebars/nodejs/index.mustache +++ b/src/main/resources/handlebars/nodejs/index.mustache @@ -1,44 +1,23 @@ 'use strict'; -var fs = require('fs'), - path = require('path'), - http = require('http'); +var path = require('path'); +var http = require('http'); -var app = require('connect')(); var oas3Tools = require('oas3-tools'); -var jsyaml = require('js-yaml'); var serverPort = {{serverPort}}; // swaggerRouter configuration var options = { - swaggerUi: path.join(__dirname, '/swagger.json'), - controllers: path.join(__dirname, './controllers'), - useStubs: process.env.NODE_ENV === 'development' // Conditionally turn on stubs (mock mode) + controllers: path.join(__dirname, './controllers') }; -// The Swagger document (require it, build it programmatically, fetch it from a URL, ...) -var spec = fs.readFileSync(path.join(__dirname,'api/swagger.yaml'), 'utf8'); -var swaggerDoc = jsyaml.safeLoad(spec); +var expressAppConfig = oas3Tools.expressAppConfig(path.join(__dirname, 'api/openapi.yaml'), options); +expressAppConfig.addValidator(); +var app = expressAppConfig.getApp(); // Initialize the Swagger middleware -oas3Tools.initializeMiddleware(swaggerDoc, function (middleware) { - - // Interpret Swagger resources and attach metadata to request - must be first in swagger-tools middleware chain - app.use(middleware.swaggerMetadata()); - - // Validate Swagger requests - app.use(middleware.swaggerValidator()); - - // Route validated requests to appropriate controller - app.use(middleware.swaggerRouter(options)); - - // Serve the Swagger documents and Swagger UI - app.use(middleware.swaggerUi()); - - // Start the server - http.createServer(app).listen(serverPort, function () { +http.createServer(app).listen(serverPort, function () { console.log('Your server is listening on port %d (http://localhost:%d)', serverPort, serverPort); console.log('Swagger-ui is available on http://localhost:%d/docs', serverPort); - }); - }); + diff --git a/src/main/resources/handlebars/nodejs/package.mustache b/src/main/resources/handlebars/nodejs/package.mustache index a80da8e03e..aac452a8ea 100644 --- a/src/main/resources/handlebars/nodejs/package.mustache +++ b/src/main/resources/handlebars/nodejs/package.mustache @@ -19,6 +19,6 @@ "connect": "^3.2.0", {{/googleCloudFunctions}} "js-yaml": "^3.3.0", - "oas3-tools": "^1.0.1" + "oas3-tools": "^2.0.0" } } diff --git a/src/main/resources/handlebars/php/api.mustache b/src/main/resources/handlebars/php/api.mustache index b8939064c3..c2fcad4d5f 100644 --- a/src/main/resources/handlebars/php/api.mustache +++ b/src/main/resources/handlebars/php/api.mustache @@ -395,13 +395,13 @@ use {{invokerPackage}}\ObjectSerializer; {{#formParams}} // form params if (${{paramName}} !== null) { - {{#isFile}} + {{#isBinary}} $multipart = true; $formParams['{{baseName}}'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue(${{paramName}}), 'rb'); - {{/isFile}} - {{^isFile}} + {{/isBinary}} + {{^isBinary}} $formParams['{{baseName}}'] = ObjectSerializer::toFormValue(${{paramName}}); - {{/isFile}} + {{/isBinary}} } {{/formParams}} // body params diff --git a/src/main/resources/handlebars/php/api_doc.mustache b/src/main/resources/handlebars/php/api_doc.mustache index 390537b72c..82b09a7432 100644 --- a/src/main/resources/handlebars/php/api_doc.mustache +++ b/src/main/resources/handlebars/php/api_doc.mustache @@ -62,7 +62,7 @@ try { {{^parameters}}This endpoint does not need any parameter.{{/parameters}}{{#parameters}}{{#@last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/@last}}{{/parameters}} -{{#parameters}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**](../Model/{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}} +{{#parameters}} **{{paramName}}** | {{#isBinary}}**{{dataType}}**{{/isBinary}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isBinary}}[**{{dataType}}**](../Model/{{baseType}}.md){{/isBinary}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}} {{/parameters}} ### Return type diff --git a/src/main/resources/handlebars/python/api.mustache b/src/main/resources/handlebars/python/api.mustache index e0ec79a8f2..72c617ad34 100644 --- a/src/main/resources/handlebars/python/api.mustache +++ b/src/main/resources/handlebars/python/api.mustache @@ -172,7 +172,7 @@ class {{classname}}(object): local_var_files = {} {{#formParams}} if '{{paramName}}' in params: - {{#notFile}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/notFile}}{{#isFile}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 + {{#notBinary}}form_params.append(('{{baseName}}', params['{{paramName}}'])){{/notBinary}}{{#isBinary}}local_var_files['{{baseName}}'] = params['{{paramName}}']{{/isBinary}}{{#isListContainer}} # noqa: E501 collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 {{/formParams}} diff --git a/src/main/resources/handlebars/python/api_doc.mustache b/src/main/resources/handlebars/python/api_doc.mustache index 1382f59f12..240a0c3bf4 100644 --- a/src/main/resources/handlebars/python/api_doc.mustache +++ b/src/main/resources/handlebars/python/api_doc.mustache @@ -65,7 +65,7 @@ except ApiException as e: {{^parameters}}This endpoint does not need any parameter.{{/parameters}}{{#parameters}}{{#@last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/@last}}{{/parameters}} -{{#parameters}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{#parameters}} **{{paramName}}** | {{#isBinary}}**{{dataType}}**{{/isBinary}}{{^isBinary}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isBinary}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} {{/parameters}} ### Return type diff --git a/src/main/resources/handlebars/typescript-angular/api.service.mustache b/src/main/resources/handlebars/typescript-angular/api.service.mustache index e25822b31f..71cc3d46d0 100644 --- a/src/main/resources/handlebars/typescript-angular/api.service.mustache +++ b/src/main/resources/handlebars/typescript-angular/api.service.mustache @@ -277,11 +277,11 @@ export class {{classname}} { let useForm = false; let convertFormParamsToString = false; {{#formParams}} -{{#isFile}} +{{#isBinary}} // use FormData to transmit files using content-type "multipart/form-data" // see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data useForm = canConsumeForm; -{{/isFile}} +{{/isBinary}} {{/formParams}} if (useForm) { formParams = new FormData();