diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java index b795f8e38e25..4f30cc01ccba 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenOperation.java @@ -30,6 +30,23 @@ public class CodegenOperation { public List> examples; public ExternalDocs externalDocs; + private boolean nonempty(List params) + { + return params != null && params.size() > 0; + } + public boolean getHasBodyParam() { + return nonempty(bodyParams); + } + public boolean getHasQueryParams() { + return nonempty(bodyParams); + } + public boolean getHasHeaderParams() { + return nonempty(bodyParams); + } + public boolean getHasPathParams() { + return nonempty(bodyParams); + } + // legacy support public String nickname; } diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache index ce881084bc2f..584db3b7a855 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache @@ -1,52 +1,158 @@ - + + + - - API Reference + {{{appName}}} + +

{{{appName}}}

-
{{{appDescription}}} for {{partner}}
+
{{{appDescription}}}
{{#infoUrl}}
More information: {{{infoUrl}}}
{{/infoUrl}} {{#infoEmail}}
Contact Info: {{{infoEmail}}}
{{/infoEmail}} {{#version}}
Version: {{{version}}}
{{/version}}
{{{licenseInfo}}}
{{{licenseUrl}}}

Access

-
Customize this message as you see fit!
-

Methods

+ {{access}} + +

Methods

+ [ Jump to Models ] + + {{! for the tables of content, I cheat and don't use CSS styles.... }} +

Table of Contents

+
{{access}}
+ {{#apiInfo}} +
    + {{#apis}} + {{#operations}} + {{#operation}} +
  1. {{httpMethod}} {{path}}
  2. + {{/operation}} + {{/operations}} + {{/apis}} +
+ {{/apiInfo}} + {{#apiInfo}} {{#apis}} - {{#operations}}{{#operation}} -
-
{{httpMethod}}: {{path}}
-
{{#tags}}{{this}}{{/tags}}
-
{{nickname}} {{summary}}
+ {{#operations}} + {{#operation}} +
+
+ Up +
{{httpMethod}} {{path}}
+
{{summary}} ({{nickname}})
+ {{! notes is operation.description. So why rename it and make it super confusing???? }}
{{notes}}
-

Parameters

+ {{#hasPathParams}} +

Path parameters

- {{#allParams}}{{>queryParam}}{{>pathParam}}{{>bodyParam}}{{>headerParam}}{{>formParam}} - {{/allParams}} + {{#pathParams}}{{>pathParam}}{{/pathParams}}
+ {{/hasPathParams}} + + {{#hasConsumes}} +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    + {{#consumes}} +
  • {{mediaType}}
  • + {{/consumes}} +
+ {{/hasConsumes}} + + {{#hasBodyParam}} +

Request body

+
+ {{#bodyParams}}{{>bodyParam}}{{/bodyParams}} +
+ {{/hasBodyParam}} + + {{#hasHeaderParam}} +

Request headers

+
+ {{#headerParam}}{{>headerParam}}{{/headerParam}} +
+ {{/hasHeaderParam}} + + {{#hasQueryParams}} +

Query parameters

+
+ {{#queryParams}}{{>queryParam}}{{/queryParams}} +
+ {{/hasQueryParams}} + + + + {{#hasExamples}} + {{#examples}} +

Example data

+
Content-Type: {{{contentType}}}
+
{{{example}}}
+ {{/examples}} + {{/hasExamples}} + + {{#hasProduces}} +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + {{#produces}} +
  • {{mediaType}}
  • + {{/produces}} +
+ {{/hasProduces}} + +

Responses

+ {{#responses}} +

{{code}}

+ {{message}} {{#examples}}

Example data

Content-Type: {{{contentType}}}
{{example}}
{{/examples}} + {{/responses}}
-
- {{/operation}}{{/operations}} - {{/apis}}{{/apiInfo}} +
+ {{/operation}} + {{/operations}} + {{/apis}} + {{/apiInfo}} + + +

Models

+ [ Jump to Methods ] + +

Table of Contents

+
    + {{#models}} + {{#model}} +
  1. {{classname}}
  2. + {{/model}} + {{/models}} +
-

Models

{{#models}} {{#model}}
-

{{classname}}

+

{{classname}} Up

{{#vars}}
{{name}} {{#isNotRequired}}(optional){{/isNotRequired}}
{{datatype}} {{description}}
{{/vars}} @@ -54,8 +160,5 @@
{{/model}} {{/models}} - \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache index 14ab06a7f7e5..d69f0e7b1617 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/style.css.mustache @@ -57,6 +57,10 @@ pre { margin-bottom: 2px; } +.http-method { + text-transform: uppercase; +} + pre.get { background-color: #0f6ab4; } @@ -96,6 +100,10 @@ code { background-color: #0f6ab4; } +.up { + float:right; +} + .parameter { width: 500px; }