forked from loafle/openapi-generator-original
[bug][html2] Fix visibility of body/response schemas (#5643)
* 1441 fix visibility of body/response schemas * Handle schemas with array items * Point to template directory in bin script * Regenerate sample Co-authored-by: Jim Schubert <james.schubert@gmail.com>
This commit is contained in:
parent
171f71872e
commit
f6572fd2f4
@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g html2 -o samples/documentation/html2 --additional-properties hideGenerationTimestamp=true $@"
|
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g html2 -o samples/documentation/html2 -t modules/openapi-generator/src/main/resources/htmlDocs2/ --additional-properties hideGenerationTimestamp=true $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
@ -5543,6 +5543,8 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
setParameterNullable(codegenParameter, codegenProperty);
|
setParameterNullable(codegenParameter, codegenProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addJsonSchemaForBodyRequestInCaseItsNotPresent(codegenParameter, body);
|
||||||
|
|
||||||
// set the parameter's example value
|
// set the parameter's example value
|
||||||
// should be overridden by lang codegen
|
// should be overridden by lang codegen
|
||||||
setParameterExampleValue(codegenParameter, body);
|
setParameterExampleValue(codegenParameter, body);
|
||||||
@ -5550,6 +5552,11 @@ public class DefaultCodegen implements CodegenConfig {
|
|||||||
return codegenParameter;
|
return codegenParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addJsonSchemaForBodyRequestInCaseItsNotPresent(CodegenParameter codegenParameter, RequestBody body){
|
||||||
|
if(codegenParameter.jsonSchema == null)
|
||||||
|
codegenParameter.jsonSchema = Json.pretty(body);
|
||||||
|
}
|
||||||
|
|
||||||
protected void addOption(String key, String description, String defaultValue) {
|
protected void addOption(String key, String description, String defaultValue) {
|
||||||
CliOption option = new CliOption(key, description);
|
CliOption option = new CliOption(key, description);
|
||||||
if (defaultValue != null)
|
if (defaultValue != null)
|
||||||
|
@ -101,6 +101,31 @@
|
|||||||
//Convert elements with "marked" class to markdown
|
//Convert elements with "marked" class to markdown
|
||||||
processMarked();
|
processMarked();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function findNode(id, currentNode) {
|
||||||
|
return (Object.keys(currentNode)[0] === id) ? currentNode : findNodeInChildren(id, currentNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
function findNodeInChildren(id, currentNode) {
|
||||||
|
for (let prop in currentNode) {
|
||||||
|
if (currentNode.hasOwnProperty(prop)) {
|
||||||
|
let currentChild = currentNode[prop];
|
||||||
|
if (id === prop) {
|
||||||
|
return currentChild;
|
||||||
|
} else {
|
||||||
|
// Search in the current child
|
||||||
|
if (typeof (currentChild) === 'object') {
|
||||||
|
let result = findNode(id, currentChild);
|
||||||
|
if (result !== false) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
{{>fonts}}
|
{{>fonts}}
|
||||||
@ -416,9 +441,14 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var schemaWrapper = {{{jsonSchema}}};
|
var schemaWrapper = {{{jsonSchema}}};
|
||||||
var schema = schemaWrapper.schema;
|
var schema = findNode('schema',schemaWrapper).schema;
|
||||||
|
if (!schema) {
|
||||||
|
schema = schemaWrapper.schema;
|
||||||
|
}
|
||||||
if (schema.$ref != null) {
|
if (schema.$ref != null) {
|
||||||
schema = defsParser.$refs.get(schema.$ref);
|
schema = defsParser.$refs.get(schema.$ref);
|
||||||
|
} else if (schema.items != null && schema.items.$ref != null) {
|
||||||
|
schema.items = defsParser.$refs.get(schema.items.$ref);
|
||||||
} else {
|
} else {
|
||||||
schemaWrapper.definitions = Object.assign({}, defs);
|
schemaWrapper.definitions = Object.assign({}, defs);
|
||||||
$RefParser.dereference(schemaWrapper).catch(function(err) {
|
$RefParser.dereference(schemaWrapper).catch(function(err) {
|
||||||
@ -505,8 +535,7 @@
|
|||||||
{{>js_json_stringify_safe}}
|
{{>js_json_stringify_safe}}
|
||||||
{{>js_webfontloader}}
|
{{>js_webfontloader}}
|
||||||
<script>
|
<script>
|
||||||
var schemaWrapper = {};
|
var schemaWrapper = { "components": { "schemas" : defs}};
|
||||||
schemaWrapper.definitions = Object.assign({}, defs);
|
|
||||||
defsParser = new $RefParser();
|
defsParser = new $RefParser();
|
||||||
defsParser.dereference(schemaWrapper).catch(function(err) {
|
defsParser.dereference(schemaWrapper).catch(function(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -4,7 +4,10 @@
|
|||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var schemaWrapper = {{{jsonSchema}}};
|
var schemaWrapper = {{{jsonSchema}}};
|
||||||
var schema = schemaWrapper.schema;
|
var schema = findNode('schema', schemaWrapper).schema;
|
||||||
|
if (!schema) {
|
||||||
|
schema = schemaWrapper.schema;
|
||||||
|
}
|
||||||
if (schema.$ref != null) {
|
if (schema.$ref != null) {
|
||||||
schema = defsParser.$refs.get(schema.$ref);
|
schema = defsParser.$refs.get(schema.$ref);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1 +1 @@
|
|||||||
3.2.1-SNAPSHOT
|
4.3.0-SNAPSHOT
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user