diff options
author | Avi Ziv <avi.ziv@amdocs.com> | 2019-06-17 13:04:58 +0300 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2019-06-18 06:45:51 +0000 |
commit | 4bf6e7f32c573b9c5096b84f6dd11674f2a53ad9 (patch) | |
tree | f22d52e7679c4cd40ec5b9f95b65ba6353f719f4 | |
parent | 47292bce13d2963a30c007995ebb36cc94f30dab (diff) |
Issue-ID: SDC-2370
Signed-off-by: dfx1971 <avi.ziv@amdocs.com>
Change-Id: Ibfe11277ab9a6f9eb0c402190e41ef94e6ae55f3
-rw-r--r-- | catalog-be/pom.xml | 36 | ||||
-rw-r--r-- | catalog-be/templates/markdown.hbs | 105 | ||||
-rw-r--r-- | catalog-be/templates/operation.hbs | 73 | ||||
-rw-r--r-- | catalog-be/templates/security.hbs | 88 | ||||
-rw-r--r-- | catalog-be/templates/strapdown.html.hbs | 11 |
5 files changed, 313 insertions, 0 deletions
diff --git a/catalog-be/pom.xml b/catalog-be/pom.xml index dfa6eaa031..a68174cd3b 100644 --- a/catalog-be/pom.xml +++ b/catalog-be/pom.xml @@ -815,6 +815,42 @@ </execution> </executions> </plugin> + <plugin> + <groupId>com.github.kongchen</groupId> + <artifactId>swagger-maven-plugin</artifactId> + <version>3.1.0</version> + <configuration> + <apiSources> + <apiSource> + <springmvc>false</springmvc> + <schemes>http</schemes> + <basePath>/sdc</basePath> + <locations>io.swagger.jaxrs.json;org.openecomp.sdc.be.externalapi.servlet;org.openecomp.sdc.be.distribution.servlet;org.openecomp.normative.api</locations> + <info> + <title>External Rest API</title> + <version>v1.0</version> + <description>External Rest API Documentation</description> + <termsOfService> + http://www.github.com/kongchen/swagger-maven-plugin + </termsOfService> + </info> + <templatePath>${basedir}/templates/strapdown.html.hbs</templatePath> + <outputPath>${basedir}/target/generated/swagger-ui/api.html</outputPath> + <swaggerDirectory>${basedir}/target/generated/swagger-ui + </swaggerDirectory> + <swaggerApiReader>io.swagger.jaxrs.config.DefaultJaxrsConfig</swaggerApiReader> + </apiSource> + </apiSources> + </configuration> + <executions> + <execution> + <phase>compile</phase> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> <pluginManagement> diff --git a/catalog-be/templates/markdown.hbs b/catalog-be/templates/markdown.hbs new file mode 100644 index 0000000000..cc87c38244 --- /dev/null +++ b/catalog-be/templates/markdown.hbs @@ -0,0 +1,105 @@ +#{{#info}}{{title}} + + +## {{join schemes " | "}}://{{host}}{{basePath}} + + +{{description}} + +{{#contact}} +[**Contact the developer**](mailto:{{email}}) +{{/contact}} + +**Version** {{version}} + +{{#license}}[**{{name}}**]({{url}}){{/license}} + +{{/info}} + +{{#if consumes}}**Consumes:** {{join consumes ", "}}{{/if}} + +{{#if produces}}**Produces:** {{join produces ", "}}{{/if}} + +{{#if securityDefinitions}} +# Security Definitions +{{/if}} +{{> security}} + +# APIs + +{{#each paths}} +## {{@key}} +{{#this}} +{{#get}} +### GET +{{> operation}} +{{/get}} + +{{#put}} +### PUT +{{> operation}} +{{/put}} + +{{#post}} +### POST + +{{> operation}} + +{{/post}} + +{{#delete}} +### DELETE +{{> operation}} +{{/delete}} + +{{#option}} +### OPTION +{{> operation}} +{{/option}} + +{{#patch}} +### PATCH +{{> operation}} +{{/patch}} + +{{#head}} +### HEAD +{{> operation}} +{{/head}} + +{{/this}} +{{/each}} + +# Definitions +{{#each definitions}} +## <a name="/definitions/{{key}}">{{@key}}</a> + +<table border="1"> + <tr> + <th>name</th> + <th>type</th> + <th>required</th> + <th>description</th> + <th>example</th> + </tr> + {{#each this.properties}} + <tr> + <td>{{@key}}</td> + <td> + {{#ifeq type "array"}} + {{#items.$ref}} + {{type}}[<a href="{{items.$ref}}">{{basename items.$ref}}</a>] + {{/items.$ref}} + {{^items.$ref}}{{type}}[{{items.type}}]{{/items.$ref}} + {{else}} + {{#$ref}}<a href="{{$ref}}">{{basename $ref}}</a>{{/$ref}} + {{^$ref}}{{type}}{{#format}} ({{format}}){{/format}}{{/$ref}} + {{/ifeq}} + </td> + <td>{{#required}}required{{/required}}{{^required}}optional{{/required}}</td> + <td>{{#description}}{{{description}}}{{/description}}{{^description}}-{{/description}}</td> + <td>{{example}}</td> + </tr> + {{/each}} +</table> +{{/each}}
\ No newline at end of file diff --git a/catalog-be/templates/operation.hbs b/catalog-be/templates/operation.hbs new file mode 100644 index 0000000000..375d4f7701 --- /dev/null +++ b/catalog-be/templates/operation.hbs @@ -0,0 +1,73 @@ +{{#deprecated}}-deprecated-{{/deprecated}} +<a id="{{operationId}}">{{summary}}</a> + +{{description}} + +{{#if externalDocs.url}}{{externalDocs.description}}. [See external documents for more details]({{externalDocs.url}}) +{{/if}} + +{{#if security}} +#### Security +{{/if}} + +{{#security}} +{{#each this}} +* {{@key}} +{{#this}} * {{this}} +{{/this}} +{{/each}} +{{/security}} + +#### Request + +{{#if consumes}} +**Content-Type: ** {{join consumes ", "}}{{/if}} + +##### Parameters +{{#if parameters}} +<table border="1"> + <tr> + <th>Name</th> + <th>Located in</th> + <th>Required</th> + <th>Description</th> + <th>Default</th> + <th>Schema</th> + </tr> +{{/if}} + +{{#parameters}} +<tr> + <th>{{name}}</th> + <td>{{in}}</td> + <td>{{#if required}}yes{{else}}no{{/if}}</td> + <td>{{description}}{{#if pattern}} (**Pattern**: `{{pattern}}`){{/if}}</td> + <td>{{#if defaultValue}}{{defaultValue}}{{else}} - {{/if}}</td> +{{#ifeq in "body"}} + <td> + {{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}} + {{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a> {{/schema.$ref}} + </td> +{{else}} + {{#ifeq type "array"}} + <td>Array[{{items.type}}] ({{collectionFormat}})</td> + {{else}} + <td>{{type}} {{#format}}({{format}}){{/format}}</td> + {{/ifeq}} +{{/ifeq}} +</tr> +{{/parameters}} +{{#if parameters}} +</table> +{{/if}} + + +#### Response + +{{#if produces}}**Content-Type: ** {{join produces ", "}}{{/if}} + + +| Status Code | Reason | Response Model | +|-------------|-------------|----------------| +{{#each responses}}| {{@key}} | {{description}} | {{#schema.$ref}}<a href="{{schema.$ref}}">{{basename schema.$ref}}</a>{{/schema.$ref}}{{#ifeq schema.type "array"}}Array[<a href="{{schema.items.$ref}}">{{basename schema.items.$ref}}</a>]{{/ifeq}}{{^schema}} - {{/schema}}| +{{/each}}
\ No newline at end of file diff --git a/catalog-be/templates/security.hbs b/catalog-be/templates/security.hbs new file mode 100644 index 0000000000..04f86e8380 --- /dev/null +++ b/catalog-be/templates/security.hbs @@ -0,0 +1,88 @@ +{{#each securityDefinitions}} +### {{@key}} +{{#this}} +{{#ifeq type "oauth2"}} +<table> + <tr> + <th>type</th> + <th colspan="2">{{type}}</th> + </tr> +{{#if description}} + <tr> + <th>description</th> + <th colspan="2">{{description}}</th> + </tr> +{{/if}} +{{#if authorizationUrl}} + <tr> + <th>authorizationUrl</th> + <th colspan="2">{{authorizationUrl}}</th> + </tr> +{{/if}} +{{#if flow}} + <tr> + <th>flow</th> + <th colspan="2">{{flow}}</th> + </tr> +{{/if}} +{{#if tokenUrl}} + <tr> + <th>tokenUrl</th> + <th colspan="2">{{tokenUrl}}</th> + </tr> +{{/if}} +{{#if scopes}} + <tr> + <td rowspan="3">scopes</td> +{{#each scopes}} + <td>{{@key}}</td> + <td>{{this}}</td> + </tr> + <tr> +{{/each}} + </tr> +{{/if}} +</table> +{{/ifeq}} +{{#ifeq type "apiKey"}} +<table> + <tr> + <th>type</th> + <th colspan="2">{{type}}</th> + </tr> +{{#if description}} + <tr> + <th>description</th> + <th colspan="2">{{description}}</th> + </tr> +{{/if}} +{{#if name}} + <tr> + <th>name</th> + <th colspan="2">{{name}}</th> + </tr> +{{/if}} +{{#if in}} + <tr> + <th>in</th> + <th colspan="2">{{in}}</th> + </tr> +{{/if}} +</table> +{{/ifeq}} +{{#ifeq type "basic"}} +<table> + <tr> + <th>type</th> + <th colspan="2">{{type}}</th> + </tr> +{{#if description}} + <tr> + <th>description</th> + <th colspan="2">{{description}}</th> + </tr> +{{/if}} +</table> +{{/ifeq}} +{{/this}} +{{/each}}
\ No newline at end of file diff --git a/catalog-be/templates/strapdown.html.hbs b/catalog-be/templates/strapdown.html.hbs new file mode 100644 index 0000000000..fe722ab6f1 --- /dev/null +++ b/catalog-be/templates/strapdown.html.hbs @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<html> +<title>API Document</title> + +<!--xmp theme="united" style="display:none;"--> +<xmp theme="united" style="display:none;"> +{{>markdown}} +</xmp> + +<script src="http://strapdownjs.com/v/0.2/strapdown.js"></script> +</html>
\ No newline at end of file |