Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.swagger.codegen.v3.generators;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.jknack.handlebars.Handlebars;
import com.samskivert.mustache.Mustache;
Expand Down Expand Up @@ -2008,7 +2009,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
}

if ("application/x-www-form-urlencoded".equalsIgnoreCase(contentType) || "multipart/form-data".equalsIgnoreCase(contentType)) {
final CodegenContent codegenContent = new CodegenContent();
final CodegenContent codegenContent = new CodegenContent(contentType);
codegenContent.getVendorExtensions().put(CodegenConstants.IS_FORM_EXT_NAME, Boolean.TRUE);

final Map<String, Schema> propertyMap = schema.getProperties();
Expand Down Expand Up @@ -2048,7 +2049,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
}
}
foundSchemas.add(schema);
final CodegenContent codegenContent = new CodegenContent();
final CodegenContent codegenContent = new CodegenContent(contentType);
codegenContent.getParameters().add(bodyParam.copy());
codegenContents.add(codegenContent);
}
Expand Down Expand Up @@ -2475,6 +2476,8 @@ public CodegenParameter fromRequestBody(RequestBody body, String name, Schema sc
codegenParameter.required = body.getRequired() != null ? body.getRequired() : Boolean.FALSE;
codegenParameter.getVendorExtensions().put(CodegenConstants.IS_BODY_PARAM_EXT_NAME, Boolean.TRUE);

codegenParameter.jsonSchema = Json.pretty(body);

if (schema == null) {
schema = getSchemaFromBody(body);
}
Expand Down
12 changes: 9 additions & 3 deletions src/main/resources/handlebars/htmlDocs2/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
<section id="api-{{baseName}}">
<h1>{{baseName}}</h1>
{{#operation}}
{{#contents}}
{{#@first}}
<div id="api-{{baseName}}-{{nickname}}">
<article id="api-{{baseName}}-{{nickname}}-0" data-group="User" data-name="{{nickname}}" data-version="0">
<div class="pull-left">
Expand Down Expand Up @@ -342,11 +344,12 @@
<script>
$(document).ready(function() {
var schemaWrapper = {{{jsonSchema}}};
var schema = schemaWrapper.schema;
var schema = schemaWrapper.content[{{contentType}}].schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
schemaWrapper.components = {};
schemaWrapper.components.schemas = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
Expand Down Expand Up @@ -395,6 +398,8 @@
</article>
</div>
<hr>
{{/@first}}
{{/contents}}
{{/operation}}
</section>
{{/operations}}
Expand Down Expand Up @@ -434,7 +439,8 @@
{{>js_webfontloader}}
<script>
var schemaWrapper = {};
schemaWrapper.definitions = Object.assign({}, defs);
schemaWrapper.components = {};
schemaWrapper.components.schemas = Object.assign({}, defs);
defsParser = new $RefParser();
defsParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/handlebars/htmlDocs2/paramB.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<script>
$(document).ready(function() {
var schemaWrapper = {{{jsonSchema}}};
var schema = schemaWrapper.schema;
var schema = schemaWrapper.content[{{contentType}}].schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
schemaWrapper.components = {};
schemaWrapper.components.schemas = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/mustache/htmlDocs2/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@
<section id="api-{{baseName}}">
<h1>{{baseName}}</h1>
{{#operation}}
{{#contents}}
{{#-first}}
<div id="api-{{baseName}}-{{nickname}}">
<article id="api-{{baseName}}-{{nickname}}-0" data-group="User" data-name="{{nickname}}" data-version="0">
<div class="pull-left">
Expand Down Expand Up @@ -342,6 +344,7 @@
<script>
$(document).ready(function() {
var schemaWrapper = {{{jsonSchema}}};
var schema = schemaWrapper.content[{{contentType}}].schema;
var schema = schemaWrapper.schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
Expand Down Expand Up @@ -395,6 +398,8 @@
</article>
</div>
<hr>
{{/-first}}
{{/contents}}
{{/operation}}
</section>
{{/operations}}
Expand Down Expand Up @@ -434,7 +439,8 @@
{{>js_webfontloader}}
<script>
var schemaWrapper = {};
schemaWrapper.definitions = defs;
schemaWrapper.components = {};
schemaWrapper.components.schemas = Object.assign({}, defs);
defsParser = new $RefParser();
defsParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/mustache/htmlDocs2/paramB.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<script>
$(document).ready(function() {
var schemaWrapper = {{{jsonSchema}}};
var schema = schemaWrapper.schema;
var schema = schemaWrapper.content[{{contentType}}].schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
schemaWrapper.components = {};
schemaWrapper.components.schemas = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
Expand Down