forked from loafle/openapi-generator-original
Html2 speed Up | Raw html using java parser instead of JS parser
This commit is contained in:
parent
4b9988c4f2
commit
e0d7c7dbd5
@ -1,14 +1,7 @@
|
|||||||
package io.swagger.codegen.languages;
|
package io.swagger.codegen.languages;
|
||||||
|
|
||||||
import io.swagger.codegen.CliOption;
|
import com.samskivert.mustache.Mustache;
|
||||||
import io.swagger.codegen.CodegenConfig;
|
import io.swagger.codegen.*;
|
||||||
import io.swagger.codegen.CodegenConstants;
|
|
||||||
import io.swagger.codegen.CodegenOperation;
|
|
||||||
import io.swagger.codegen.CodegenParameter;
|
|
||||||
import io.swagger.codegen.CodegenResponse;
|
|
||||||
import io.swagger.codegen.CodegenType;
|
|
||||||
import io.swagger.codegen.DefaultCodegen;
|
|
||||||
import io.swagger.codegen.SupportingFile;
|
|
||||||
import io.swagger.models.Info;
|
import io.swagger.models.Info;
|
||||||
import org.yaml.snakeyaml.error.Mark;
|
import org.yaml.snakeyaml.error.Mark;
|
||||||
import io.swagger.codegen.utils.Markdown;
|
import io.swagger.codegen.utils.Markdown;
|
||||||
@ -129,6 +122,7 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
|
|||||||
response.code = "default";
|
response.code = "default";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
op.formParams = postProcessParameterEnum(op.formParams);
|
||||||
}
|
}
|
||||||
return objs;
|
return objs;
|
||||||
}
|
}
|
||||||
@ -215,6 +209,30 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format to HTML the enums contained in every operations
|
||||||
|
*
|
||||||
|
* @param parameterList The whole parameters contained in one operation
|
||||||
|
* @return String | Html formated enum
|
||||||
|
*/
|
||||||
|
public List<CodegenParameter> postProcessParameterEnum(List<CodegenParameter> parameterList) {
|
||||||
|
String enumFormatted = "";
|
||||||
|
for(CodegenParameter parameter : parameterList) {
|
||||||
|
if (parameter.isEnum) {
|
||||||
|
for (int i = 0; i < parameter._enum.size(); i++) {
|
||||||
|
String spacer = (i == (parameter._enum.size() - 1)) ? " " : ", ";
|
||||||
|
|
||||||
|
if (parameter._enum.get(i) != null)
|
||||||
|
enumFormatted += "`" + parameter._enum.get(i) + "`" + spacer;
|
||||||
|
}
|
||||||
|
Markdown markInstance = new Markdown();
|
||||||
|
if (!enumFormatted.isEmpty())
|
||||||
|
parameter.vendorExtensions.put("x-eumFormatted", markInstance.toHtml(enumFormatted));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parameterList;
|
||||||
|
}
|
||||||
|
|
||||||
private String sanitizePath(String p) {
|
private String sanitizePath(String p) {
|
||||||
//prefer replace a ', instead of a fuLL URL encode for readability
|
//prefer replace a ', instead of a fuLL URL encode for readability
|
||||||
return p.replaceAll("'", "%27");
|
return p.replaceAll("'", "%27");
|
||||||
|
@ -59,11 +59,6 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// load google web fonts
|
|
||||||
loadGoogleFontCss();
|
|
||||||
|
|
||||||
|
|
||||||
// Bootstrap Scrollspy
|
// Bootstrap Scrollspy
|
||||||
$(this).scrollspy({ target: '#scrollingNav', offset: 18 });
|
$(this).scrollspy({ target: '#scrollingNav', offset: 18 });
|
||||||
|
|
||||||
@ -105,21 +100,6 @@
|
|||||||
|
|
||||||
//Convert elements with "marked" class to markdown
|
//Convert elements with "marked" class to markdown
|
||||||
processMarked();
|
processMarked();
|
||||||
|
|
||||||
/**
|
|
||||||
* Load google fonts.
|
|
||||||
*/
|
|
||||||
function loadGoogleFontCss() {
|
|
||||||
WebFont.load({
|
|
||||||
active: function() {
|
|
||||||
// Update scrollspy
|
|
||||||
$(window).scrollspy('refresh')
|
|
||||||
},
|
|
||||||
google: {
|
|
||||||
families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7']
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
@ -132,10 +112,10 @@
|
|||||||
<script>
|
<script>
|
||||||
// Script section to load models into a JS Var
|
// Script section to load models into a JS Var
|
||||||
var defs = {}
|
var defs = {}
|
||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
defs.{{name}} = {{{modelJson}}};
|
defs.{{name}} = {{{modelJson}}};
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -359,7 +339,7 @@
|
|||||||
{{#schema}}
|
{{#schema}}
|
||||||
<div class="tab-pane active" id="responses-{{nickname}}-{{code}}-schema">
|
<div class="tab-pane active" id="responses-{{nickname}}-{{code}}-schema">
|
||||||
<div id='responses-{{nickname}}-{{code}}-schema-{{code}}' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
|
<div id='responses-{{nickname}}-{{code}}-schema-{{code}}' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var schemaWrapper = {{{jsonSchema}}};
|
var schemaWrapper = {{{jsonSchema}}};
|
||||||
var schema = schemaWrapper.schema;
|
var schema = schemaWrapper.schema;
|
||||||
|
@ -258,7 +258,7 @@ var JSONSchemaView = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.isArray) {
|
if (this.isArray) {
|
||||||
var view = new JSONSchemaView(this.schema.items, this.open - 1);
|
var view = new JSONSchemaView(this.schema.items, Infinity);
|
||||||
inner.appendChild(view.render());
|
inner.appendChild(view.render());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,25 +2,39 @@
|
|||||||
<td>
|
<td>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<div id="d2e199_{{nickname}}_{{paramName}}">
|
||||||
$(document).ready(function() {
|
<div class="json-schema-view">
|
||||||
var schemaWrapper = {{{jsonSchema}}};
|
<div class="primitive">
|
||||||
var schema = schemaWrapper;
|
<span class="type">
|
||||||
|
{{dataType}}
|
||||||
|
</span>
|
||||||
|
{{#dataFormat}}
|
||||||
|
<span class="format">
|
||||||
|
({{dataFormat}})
|
||||||
|
</span>
|
||||||
|
{{/dataFormat}}
|
||||||
|
|
||||||
|
{{#description}}
|
||||||
|
<div class="inner description">
|
||||||
|
{{description}}
|
||||||
var view = new JSONSchemaView(schema,1);
|
</div>
|
||||||
var result = $('#d2e199_{{nickname}}_{{paramName}}');
|
{{/description}}
|
||||||
result.empty();
|
</div>
|
||||||
result.append(view.render());
|
{{#isEnum}}
|
||||||
|
{{#vendorExtensions.x-eumFormatted}}
|
||||||
|
<div class="inner enums" id="{{nickname}}_{{paramName}}_enum">
|
||||||
|
<span class="inner">
|
||||||
|
<b>Enum: </b>{{{vendorExtensions.x-eumFormatted}}}
|
||||||
|
</span>
|
||||||
});
|
</div>
|
||||||
</script>
|
{{/vendorExtensions.x-eumFormatted}}
|
||||||
<div id="d2e199_{{nickname}}_{{paramName}}"></div>
|
{{/isEnum}}
|
||||||
|
{{#required}}
|
||||||
|
<div class="inner required">
|
||||||
|
Required
|
||||||
|
</div>
|
||||||
|
{{/required}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
/* ------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------
|
||||||
* Content
|
* Content
|
||||||
* ------------------------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro');
|
||||||
|
* {
|
||||||
|
font-family: 'Source Code Pro', sans-serif;
|
||||||
|
}
|
||||||
body {
|
body {
|
||||||
min-width: 980px;
|
min-width: 980px;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user