-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
I'm using the develop_2.0 branch of swagger-codegen
I'm trying to generate static HTML for several swagger 2.0 documents.
The static HTML omits the list of http responses, as well as the
headers and the "produces" value.
Example: input swagger.json:
{
"swagger" : "2.0",
"info" : {
"title" : "issue with swagger-codegen and empty results",
"contact" : {
"name" : "David Biesack",
"email" : "[email protected]"
},
"version" : "1"
},
"host" : "www.example.com",
"basePath" : "/",
"schemes" : ["http"],
"paths" : {
"/" : {
"get" : {
"summary" : "Return a list of links to the top level collections in this REST API, as well as links to create new instances in the top level collections.",
"produces" : ["application/json"],
"responses" : {
"200" : {
"description" : "REST API resource collection links."
}
}
}
},
"/models/{modelId}" : {
"get" : {
"summary" : "Get headers for a model",
"parameters" : [{
"name" : "modelId",
"in" : "path",
"type" : "string",
"required" : true,
"description" : "String containing the id of the model."
}
],
"produces" : [ "application/json"],
"responses" : {
"200" : {
"description" : "Return a specific model resource status code.",
"schema" : { "$ref": "#/definitions/Model" },
"headers" : {
"Content-Type" : {
"description" : "The media type of the response, application/vnd.sas.model+json",
"type" : "string"
},
"Content-Length" : {
"description" : "The size of the response, in bytes",
"type" : "integer",
"format" : "long"
},
"Last-Modified" : {
"description" : "When the resource was last modified",
"type" : "string",
"format" : "dateTime"
}
}
},
"403" : {
"description" : "The project is not locked by the current user."
},
"404" : {
"description" : "Not found."
},
"423" : {
"description" : "The project is locked by a different user."
}
}
}
}
},
"definitions" : {
"Model" : {
"id" : "Model",
"title" : "A model",
"properties" : {
"id" : {
"type" : "string",
"description" : "The model id."
},
"context" : {
"type" : "string",
"description" : "The context"
}
}
}
}
}
the output HTML does not list the "200" response code, description or the "produces" value (no indication of what the "Accept" header should be). Nor are the 403, 404, or 423 status codes listed.
The generated HTML contains only a link to the Model schema.
Here is the emitted HTML
<html lang="en">
<head>
<meta charset="utf-8" />
<title>API Reference</title>
<link rel="stylesheet" type="text/css" href="site.css" media="screen" />
</head>
<body>
<h1>issue with swagger-codegen and empty results</h1>
<div class="app-desc">A sample swagger server for our Partner</div>
<div class="app-desc">Contact Info: <a href="[email protected]">[email protected]</a></div>
<div class="license-info">All rights reserved</div>
<div class="license-url">http://apache.org/licenses/LICENSE-2.0.html</div>
<h2>Access</h2>
<div class="method-summary">Access to the API requires an api key to be provided by our Partner for all requests. The api key is passed as a header with the name `api_key` and the value provided by Reverb Technologies, Inc. Unless otherwise agreed upon, access to the Reverb API is intended solely for usage by our Partner and not third parties.</div>
<h2>Methods</h2>
<div class="method">
<div class="method-path"><pre class="get"><code class="huge"><span>get</span>: /</code></pre></div>
<div class="method-summary"><span class="nickname">rootGet</span> Return a list of links to the top level collections in this REST API, as well as links to create new instances in the top level collections.</div>
<div class="method-notes"></div>
<h3 class="field-label">Parameters</h3>
<div class="field-items">
</div> <!-- field-items -->
<h3 class="field-label">Return type</h3>
<div class="return-type"><a href="#"></a></div>
</div> <!-- method -->
<hr>
<div class="method">
<div class="method-path"><pre class="get"><code class="huge"><span>get</span>: /models/{modelId}</code></pre></div>
<div class="method-summary"><span class="nickname">modelsModelIdGet</span> Get headers for a model</div>
<div class="method-notes"></div>
<h3 class="field-label">Parameters</h3>
<div class="field-items">
<div class="param">modelId (required)</div>
<div class="param-desc"><span class="param-type">Path Parameter</span> — String containing the id of the model. </div>
</div> <!-- field-items -->
<h3 class="field-label">Return type</h3>
<div class="return-type"><a href="#">Model</a></div>
</div> <!-- method -->
<hr>
<h2>Models</h2>
<div class="model">
<h3 class="field-label"><a name="Model">Model</a></h3>
<div class="field-items">
<div class="param">id </div><div class="param-desc"><span class="param-type">String</span> The model id.</div>
<div class="param">context </div><div class="param-desc"><span class="param-type">String</span> The context</div>
</div> <!-- field-items -->
</div>
<style>
body {
font-family: Trebuchet MS, sans-serif;
font-size: 15px;
color: #444;
margin-right: 24px;
}
h1 {
font-size: 25px;
}
h2 {
font-size: 20px;
}
h3 {
font-size: 16px;
font-weight: bold;
}
hr {
height: 1px;
border: 0;
color: #ddd;
background-color: #ddd;
display: none;
}
.app-desc {
clear: both;
margin-left: 20px;
}
.param-name {
width: 100%;
}
.license-info {
margin-left: 20px;
}
.license-url {
margin-left: 20px;
}
.model {
margin: 0 0 0px 20px;
}
.method {
margin-left: 20px;
}
.method-notes {
margin: 10px 0 20px 0;
font-size: 90%;
color: #555;
}
pre {
padding: 10px;
}
pre.get {
background-color: #0f6ab4;
}
pre.post {
background-color: #10a54a;
}
pre.put {
background-color: #c5862b;
}
pre.delete {
background-color: #a41e22;
}
.huge {
color: #fff;
}
pre.example {
background-color: #f3f3f3;
padding: 10px;
border: 1px solid #ddd;
}
code {
white-space: pre;
}
.nickname {
font-weight: bold;
}
.method-path {
font-size: 1.5em;
background-color: #0f6ab4;
}
.parameter {
width: 500px;
}
.param {
width: 500px;
padding: 10px 0 0 20px;
font-weight: bold;
}
.param-desc {
width: 700px;
padding: 0 0 0 20px;
color: #777;
}
.param-type {
font-style: italic;
}
.field-label {
padding: 0;
margin: 0;
clear: both;
}
.field-items {
padding: 0 0 15px 0;
margin-bottom: 15px;
}
.return-type {
clear: both;
padding-bottom: 10px;
}
.param-header {
font-weight: bold;
}
</style>
</body>
</html>
This was created by copying the html-petstore.sh and changing the args
-i http://localhost/.../issues/swagger-codegen-xxx/swagger.json -l html -o samples/swagger-codegen-issue-xxx"
Also, it would be nice if the sections Access, Methods, and Models had anchors. (I know I can customize the mustache templates, but the default should include these.)
Finally, note that the emitted HTML includes an ASL 2.0 that is not in the input swagger.json,
as well as some additional info about api keys and Reverb (also not in the input).
I will submit a separate issue for that, citing this example for input.